Skip to content

JSON Formatter and Validator

Format, minify and validate JSON in your browser, with exact error locations, repairs for comments and trailing commas, and a tree view.

  • Free, no sign-up
  • Runs in your browser
  • Sources cited

Orders the names in every object alphabetically, by Unicode code point.

Writes characters outside ASCII as \u escapes.

Also reads // and /* */ comments, trailing commas and single quotes, which standard JSON does not allow, and writes standard JSON.

Valid JSON

Input 282 B → Output 460 B · 163% of the input

Paste or type JSON, or drop a file here. It stays on your device.

Formatted JSON

{
  "order": {
    "id": "A-1042",
    "placed": "2026-03-14T09:30:00Z",
    "customer": {
      "name": "Sam Rivera",
      "email": "sam@example.com"
    },
    "items": [
      {
        "sku": "BK-001",
        "title": "Field notes",
        "quantity": 1,
        "price": 24.50
      },
      {
        "sku": "PN-210",
        "title": "Fountain pen",
        "quantity": 2,
        "price": 12
      }
    ],
    "paid": true,
    "coupon": null
  }
}

What the document holds

Objects
5
Arrays
1
Names
17
Strings
8
Numbers
4
True or false
1
Nulls
1
Depth
5
Lines
26

How to use the JSON formatter

  1. Add your JSON

    Paste or type it into the input, open a file, or drop a file onto the input. Files up to 5 MB work, and nothing is uploaded: formatting runs in your browser.

  2. Choose the layout

    Pick two spaces, four spaces or tabs for indentation, or minify to remove all spacing. Turn on sorting to order the names in every object, or escaping to write every non-ASCII character as a \u escape.

  3. Read the result

    The status bar says whether the JSON is valid. If it is not, it gives the line and column, explains what is wrong in plain words, shows the line with a marker under the problem, and can select that spot in the input for you.

  4. Repair common extras

    If the text has comments, trailing commas or single quotes, which standard JSON does not allow, turn on “Accept comments and trailing commas” and the output is standard JSON.

  5. Check the warnings

    Valid JSON can still cause problems. The formatter points out names used twice in one object, and numbers that most programs would read differently.

  6. Copy, download or browse

    Copy the result, download it as a file, use it as the new input, or switch to the tree view to fold and unfold the document and copy the path of any value.

How JSON is checked and formatted

JSON is defined by RFC 8259, the IETF standard published in December 2017, and by ECMA-404. A JSON text is a single value: an object, an array, a string, a number, or one of true, false and null. Objects hold names and values, and arrays hold lists of values.

The formatter reads your text with its own parser, written to the grammar in RFC 8259, rather than the parser built into the browser. That lets it say exactly where an error is and why, keep every number exactly as you wrote it, and report names used twice in one object. It then writes the document back out with the layout you choose. Formatting only changes spacing, the order of names if you ask for sorting, and how characters are escaped; values never change.

What standard JSON allows, from RFC 8259
PartThe rule
SpacingOnly space, tab, line feed and carriage return, before or after the structural characters
Strings and namesIn double quotes. Quotation marks, backslashes and control characters must be escaped
Escapes\" \\ \/ \b \f \n \r \t, and \u followed by four hexadecimal digits
NumbersWritten in decimal, with an optional fraction and exponent. Infinity and NaN are not permitted
Names in an objectShould be unique
Comments, trailing commasNot part of the grammar
EncodingUTF-8 for JSON exchanged between systems, with no byte order mark

The older RFC 4627, from 2006, allowed only an object or an array as a whole JSON text. Under RFC 8259 any value is a valid JSON text, so a lone string or number is valid here too.

Large documents are formatted in a background thread of your browser, so the page stays responsive while you type, and very slow work is stopped rather than left to freeze the page.

Worked example: repairing hand-written JSON

Here is JSON written by hand, the way it often appears in configuration files and chat messages: { 'name': 'Ada', "languages": ["English", "French",], }

  1. The formatter reports it as not valid, at Line 1, column 3: “Strings and names in JSON use double quotes, not single quotes.”
  2. With “Accept comments and trailing commas” turned on, it reads the text anyway and says what it changed: Removed 2 trailing commas. Changed 2 single-quoted strings to double quotes.
  3. Minified, the repaired JSON is {"name":"Ada","languages":["English","French"]}
  4. With two-space indentation, the same document takes 7 lines, one value per line.

A missing comma is found the same way. In an object whose second name follows the first value with no comma between them, the formatter stops at Line 3, column 3 and says: “Expected a comma or a closing bracket, but found “"”. A comma may be missing between two values.”

Understanding the result

  • Valid

    The text follows the JSON grammar. The status bar shows its size before and after formatting: the example on this page is 282 bytes as written, and 460 bytes over 26 lines with two-space indentation.

  • Not valid

    The first problem is shown with its line and column. Fix it and the formatter moves on to the next one, if any. The marker points at the character where reading stopped, which is often just after the real mistake, such as a missing comma.

  • Repaired

    The text was not standard JSON, but only because of comments, trailing commas or single quotes. The output is standard JSON, and the status bar lists what was changed.

  • Minified

    Minifying removes every optional space and line break. The example on this page minifies to 282 bytes, 61% of its formatted size.

Large numbers. RFC 8259 notes that many programs read numbers as IEEE 754 double-precision values, so integers between minus and plus 9007199254740991 are read exactly everywhere, and that numbers beyond that precision may indicate potential interoperability problems. For example, 12345678901234567890 is read by such programs as 12345678901234567000. The formatter keeps it exactly as written and warns you, so you can decide whether to send it as a string instead.

Repeated names. RFC 8259 says the names within an object should be unique, and that when they are not, programs behave unpredictably: many keep only the last value, others report an error, and some keep every value. The formatter keeps every value and lists each repeated name with its path.

  • Trailing commas. A comma after the last item of an array or object is not allowed.
  • Single quotes. JSON strings and names use double quotes only.
  • Comments. JSON has no comment syntax, so // and /* */ make the text invalid.
  • Names without quotes. Every name in a JSON object must be a string in double quotes.
  • NaN, Infinity and undefined. JSON has no such values. Use null, or a string.
  • More than one value. A JSON text is one value. Put several values in an array.

When it helps

  • Reading an API response

    Turn a long single line from an API or a log into an indented document you can read, or a tree you can fold.

  • Finding a syntax error

    Find the exact line and column of the problem in a configuration file, rather than reading a vague error from another program.

  • Cleaning hand-written JSON

    Repair JSON copied from documentation or written by hand, with comments and trailing commas, into standard JSON.

  • Making files smaller

    Minify JSON before sending or storing it, and see how much smaller it is.

  • Comparing documents

    Sort the names of two documents the same way, so the same data looks the same, ready for a side-by-side comparison.

  • Checking data before it is sent

    Catch repeated names and numbers too large for most programs before they cause problems elsewhere.

Frequently asked questions

Is my JSON uploaded anywhere?

No. Formatting and checking run in your browser, including for large files, and the JSON is never put in a shareable link. A shared link carries only your layout settings.

Why does it say my JSON is invalid when my program accepts it?

Some programs accept extras that standard JSON does not allow, such as comments, trailing commas or single quotes; RFC 8259 lets parsers accept such extensions. The formatter checks against the standard, and can repair these extras for you.

Does formatting change my data?

No. It changes spacing, and the order of names only if you turn sorting on. Numbers are written exactly as you wrote them, so 24.50 stays 24.50. Only escapes may change: characters are written with the shortest standard escape, or as \u escapes if you choose.

Can a JSON file be just a string or a number?

Yes. Under RFC 8259 a JSON text can be any value. The older RFC 4627 allowed only an object or an array.

Why is my large number flagged?

Because many programs read numbers as double-precision values, which cannot hold every digit of very large or very precise numbers. The formatter keeps your number exactly and tells you it may be read differently elsewhere.

What does sorting do to arrays?

Nothing. Sorting orders the names inside objects. The order of items in an array is part of the data, so it never changes.

How large a file can it handle?

Up to 5 MB of text. Large documents are formatted in a background thread so the page stays responsive, and are shown without colours to keep scrolling smooth.

Sources

  1. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange FormatInternet Engineering Task Force (IETF) · retrieved Nov 6, 2026
  2. RFC 4627: The application/json Media Type for JavaScript Object Notation (JSON)Internet Engineering Task Force (IETF) · retrieved Nov 6, 2026
  3. ECMA-404: The JSON data interchange syntaxEcma International · retrieved Nov 6, 2026

About these results

  • The formatter checks against RFC 8259. Programs that accept extensions may accept text it reports as invalid.
  • The formatter runs in your browser. Nothing you enter is sent to ObjectiveLine.