How to use the JSON formatter
- Paste JSON into the input box, or press Open file to load a
.jsonfile from your computer. The file is read by your browser, not uploaded. - Choose an indent (2 spaces, 4 spaces or tabs) and, if you want, tick Sort keys A to Z.
- Press Format to pretty print, Minify to strip whitespace, or Validate to only check it.
- Switch to Tree to fold and unfold objects and arrays, then Copy or Download the result.
Reading the error messages
When JSON is invalid, the formatter stops at the first problem and tells you where it is, for example "Line 3, column 30: Trailing comma is not allowed". Lines and columns count from 1, and a tab counts as one column. The line is shown with a caret under the character, and Go to error selects it in the input so you can fix it. This text has two trailing commas, which most JavaScript code accepts but JSON does not:
{
"name": "Ada",
"tags": ["admin", "editor",],
} The most common mistakes, and what to do about them:
- Trailing comma. Remove the comma after the last item in an object or array.
- Missing comma. Items in arrays and pairs in objects need a comma between them. The error usually points at the start of the next item.
- Single quotes or unquoted keys. Write
"name", not'name'orname. - Comments. JSON has none. Delete
//and/* */comments, or keep the file as JSONC if your tool reads that. - Special values.
NaN,Infinity,undefinedand hexadecimal numbers are JavaScript, not JSON. Usenullor a string. - Raw line breaks or tabs inside strings. Write them as
\nand\t. - Several documents in one box. A JSON text holds exactly one value. For JSON Lines (one object per line), format one line at a time.
What JSON is
JSON (JavaScript Object Notation) is a plain-text format for structured data. It is defined by RFC 8259 and ECMA-404 and is used by almost every web API, many configuration files and most databases that store documents. A JSON value is one of six kinds:
- Object: an unordered set of name and value pairs in curly braces. Names are always double-quoted strings.
- Array: an ordered list of values in square brackets.
- String: text in double quotes, with backslash escapes such as
\",\\andé. - Number: a decimal number, optionally negative, with an optional fraction and exponent. No leading zeros, no plus sign, no hex.
- true and false.
- null.
Whitespace between those pieces (spaces, tabs, line breaks) has no meaning, which is why the same data can be shown formatted for people or minified for machines. Formatting changes nothing about the data itself.
Why this formatter keeps your numbers exact
Many online formatters run your text through the browser's JSON.parse and print the result. That
quietly changes some data: integers above 9,007,199,254,740,991 (253 - 1) are rounded, so an ID like
12345678901234567890 comes back as 12345678901234567000; numbers such as
1.0 lose their trailing zero; and keys that look like numbers jump to the front of each object.
This tool uses its own parser instead, keeps every number and string exactly as you wrote it, and keeps keys in their
original order unless you ask it to sort them.
Duplicate keys
RFC 8259 says object names "SHOULD be unique" but does not forbid repeats, and different programs handle them differently (most keep the last value). The formatter keeps duplicates as they are and warns you about the first one so you can decide which value is right.
Limits
- Strict JSON only: no comments, trailing commas, single quotes or JSON5 extras. That matches what APIs accept.
- Files of several megabytes format fine, but the tree view shows at most 5,000 entries so the page stays responsive. The text view always shows everything.
- Extremely deep nesting (thousands of levels) may exceed the browser's limits and is reported as an error.
Related tools
Need IDs for test data? The UUID generator makes v4 and v7 UUIDs in bulk. Timestamps in an API response? Paste them into the Unix timestamp converter. Writing documentation for an API? The Markdown to HTML converter turns notes into clean HTML, and our GitHub Copilot review looks at AI help for writing the code itself.