JSON Formatter and Validator

Paste JSON to check it, repair it and make it readable or compact. The text is processed on your device and is never uploaded.

Runs in your browser. Your input is not sent anywhere.

Paste or type JSON. It is checked while you type.

By Unicode code point at every level; arrays keep their order.

Off by default. When on, the fields of this tool are kept in the local storage of this browser, unencrypted, until you turn it off.

No JSON yet

Your result will appear here.

Keyboard shortcuts

Ctrl + Enter, ⌘ + Enter
Run the tool with the current input
Alt + Shift + C
Copy the result
Alt + Shift + X
Clear all fields

Shortcuts work while the focus is inside the tool. Every action is also available as a button.

What this tool does

The tool checks whether a text is valid JSON as defined by RFC 8259. If it is, the tool writes it again with the indentation you choose, or without any whitespace. If it is not, the tool names the first error and its line and column, and selects the offending character in the input field.

Only the whitespace between values changes. Strings, numbers and the order of properties are copied exactly as you wrote them, unless you ask for sorted keys.

Three more tasks share the page: “Repair, then format” fixes comments, trailing commas, single quotes and unquoted keys and lists each fix; “Escape text as a JSON string” and “Unescape a JSON string” convert between plain text and a string literal. A collapsible tree shows the structure of large documents.

How to use it

  1. Paste or type JSON into the field “JSON text”.
  2. Choose a task. “Validate and format” is the default; choose “Repair, then format” for text copied from JavaScript, a JSON5 or JSONC configuration file or a log.
  3. Choose an output style: indentation with 2 spaces, 4 spaces or tabs, or “Minify: remove all whitespace”. Turn on “Sort object keys” or the tree if you need them.
  4. Read the result on the right, or below the input on a narrow screen. It appears while you type.
  5. Select “Copy result” or “Download result” to take the result with you.

Input of more than 200,000 characters is not processed while you type. Select “Format” to start. Of a long result the first 200,000 characters are shown; copying and downloading use the complete result.

How the result is derived

The tool reads the text character by character and follows the grammar of JSON: a value is an object, an array, a string, a number, or one of the words true, false and null. When a character does not fit the grammar, reading stops and its position is reported.

Many formatters convert the text into JavaScript values and write those values out again. That changes numbers that JavaScript cannot represent exactly and drops duplicate property names. This tool does not convert values, so the output always describes the same data as the input.

Input that a converting formatter would change
{"id": 12345678901234567890, "price": 1.10, "a": 1, "a": 2}

After a round trip through JavaScript values the identifier becomes 12345678901234567000, the price becomes 1.1 and only the second “a” remains. Here all of them stay as they are.

Worked example

The following text has a comma after the last element of the array.

Invalid JSON
{"name": "Ada",
 "tags": ["a", "b",]}

The tool reports line 2, column 20: a value is expected, but a closing bracket was found. Remove the comma and the text is valid. With 2 spaces it is written like this:

Formatted result
{
  "name": "Ada",
  "tags": [
    "a",
    "b"
  ]
}

Repair: what is fixed and what is not

Repair changes only what has one obvious meaning, and lists every change with its line and column so that you can check it. The repaired text is then validated like any other; whatever remains is reported as an error at its position in your original text.

Repairs
FoundChanged to
// comment to the end of the lineRemoved
/* comment */Removed; a space keeps the tokens apart
[1, 2,] or {"a": 1,}The last comma removed
'text'"text", with \' unescaped and " escaped
{name: 1}{"name": 1}, for keys made of letters, digits, _ and $

Not repaired, because the right replacement depends on the program that wrote the text: undefined, NaN and Infinity; True, False and None from Python; hexadecimal numbers; line breaks inside strings; missing commas; several values in one text. Comment markers inside strings, as in "http://example.com", are left alone.

Input with comments and JavaScript syntax
{
  // owner
  name: 'Ada',
  tags: ['b', 'a',],
}

The tool makes eight repairs: the comment, two unquoted keys, three single-quoted strings and two trailing commas, and returns {"name": "Ada", "tags": ["b", "a"]} formatted as chosen.

Sorting keys, the tree and escaped strings

With “Sort object keys”, the keys of every object are ordered by Unicode code point, so upper case comes before lower case and accented letters after both. This is the order jq -S and Python’s json.dumps(sort_keys=True) print, which makes the output of the three comparable. Arrays keep their order, because in JSON it is part of the data. Sorting needs unique keys; a key that occurs twice in one object is reported instead of silently dropped.

The tree shows each object and array as a line you can open and close, with the number of keys or items. It is built from the same parsed data as the text result, so large numbers keep all their digits. Documents with more than 1000 values open two levels deep, and at most 5000 values are drawn.

Escaping turns any text into a JSON string literal: quotation marks, backslashes and control characters become \", \\ and \n, \t or \u0000 forms, the way JSON.stringify writes them. Unescaping does the reverse and accepts the literal with or without its surrounding quotes. Use it to read a JSON value that was stored as a string inside another JSON document, a common sight in logs and message queues.

Text and its JSON string
Text:         say "hi"
              bye
JSON string:  "say \"hi\"\nbye"

Reference: the rules of JSON

JSON values according to RFC 8259
ValueRulesExample
ObjectBraces around pairs of a name and a value. Names are strings in double quotes.{"a": 1, "b": 2}
ArraySquare brackets around values separated by commas.[1, "two", null]
StringDouble quotes. A double quote, a backslash and the control characters U+0000 to U+001F must be escaped."line\nbreak"
NumberDecimal digits with an optional minus sign, fraction and exponent. No leading zeros, no plus sign, no NaN or Infinity.-12.5e3
Literal namesExactly true, false and null, in lower case.true

A JSON text is a single value of any of these kinds. Whitespace between values may be a space, a tab, a line feed or a carriage return. The grammar has no comments and allows no comma after the last element.

The names in an object should be unique. The standard does not forbid duplicates, but programs disagree about what they mean, so avoid them.

Numbers may have any number of digits in the text. For exchange between programs the standard points out that many of them store numbers as 64-bit floating point values, in which integers are exact only from −(2^53) + 1 to 2^53 − 1. Send larger identifiers as strings.

Common mistakes

  • A comma after the last element of an array or object.
  • Single quotes instead of double quotes, or property names without quotes. Both are allowed in JavaScript code but not in JSON.
  • Comments. Remove them before the text is parsed.
  • A line break inside a string. Write it as a backslash followed by n.
  • True, False or None copied from Python output, and undefined or NaN copied from JavaScript.
  • Two values in one text, for example one object per line. That is the JSON Lines convention, not a JSON text; check the lines one at a time.

Sources

Frequently asked questions

Is my JSON uploaded?
No. The text is checked and formatted by a script in the page. It is not sent to a server and not stored, unless you turn on “Remember my input on this device”.
Can it sort the keys of a JSON object?
Yes. Turn on “Sort object keys”. Keys are sorted at every level by Unicode code point, as jq -S does; arrays keep their order. Without the option the order of properties is kept exactly, because some programs depend on it.
Can it fix JSON with comments or trailing commas?
Yes, with the task “Repair, then format”. It removes comments and trailing commas, changes single quotes to double quotes and quotes bare keys, and lists every change. “Validate and format” still checks strictly against the JSON standard, because that is what JSON parsers in programs accept.
How large can the input be?
There is no fixed limit. In our test a document of 3 megabytes was formatted within a few seconds in a desktop browser. Large input is processed only when you select “Format”, and long results are shown in part to keep the page responsive.
What does the column number count?
Characters from the start of the line, beginning with 1. A character outside the Basic Multilingual Plane, such as an emoji, counts as one character.

Last updated: September 29, 2026