Skip to content

JSON Formatter

To format JSON online, paste it into the box. It is checked and indented with 2 spaces as you type, because Format is already selected; pick 4 spaces or a tab, sort the keys A to Z, or pick Minify for one line. Errors show their line and column, repeated keys are flagged, and numbers keep their exact digits.

Making one-line JSON readable

Before

{"name":"Ayesha","tools":["pdf","photo"],"free":true}

JSON on one line

After

{ "name": "Ayesha", "tools": [ "pdf", "photo" ], "free": true }

Indented and checked

Input JSON

Indent

Try sample JSON:

Formatted JSON

Formatted JSON will appear here...

Usage tips

  • Format: Pretty-print JSON with a 2-space, 4-space or tab indent
  • Sort keys: Put every object's keys in A to Z order, so two files are easy to compare
  • Minify: Remove all whitespace to reduce file size
  • Validate: JSON is checked as you type. Errors show the line and column when your browser reports them
  • Numbers keep the exact digits you pasted: 1e400, -0, 1.50 and long IDs are not rounded or rewritten
  • A key used twice in the same object gets a warning, because most parsers keep only the last value

How to format and validate JSON

  1. Paste JSON into the input box, or click a sample to see how it works. It is checked as you type.
  2. If it is invalid, read the message under the box and go to the line and column it names. Fix that spot and the error clears on its own.
  3. Pick Format to indent it for reading, with 2 spaces, 4 spaces or a tab, or Minify to strip the whitespace for sending or storing. Tick Sort keys A to Z to put the keys of every object in order.
  4. Copy the result, or download it as formatted.json or minified.json. To read the JSON inside a token, use JWT Decoder.

Frequently asked questions

How do I validate JSON online?

Paste it into the box and look under it: it says Valid JSON, or Invalid JSON with the error message and, when your browser gives one, the line and column. The check uses your browser's own JSON parser, the same one web apps use, so JSON that passes here will parse in a browser.

Why is my JSON invalid when it looks fine?

The usual causes are a comma after the last item, single quotes instead of double quotes, keys without quotes, comments, or values like undefined and NaN. JavaScript code allows all of these, but the JSON grammar in RFC 8259 does not.

Sources: IETF, RFC 8259: The JSON data interchange format

Does formatting change my numbers?

No. Every number is printed exactly as you wrote it, so 0.10 stays 0.10 and a 19-digit ID keeps all its digits. Integers beyond 9,007,199,254,740,991 get a warning, because RFC 8259 notes that only integers up to that size are safe to exchange and many tools round larger ones.

Sources: IETF, RFC 8259: The JSON data interchange format

Are duplicate keys removed?

No. The formatter prints your JSON as written, so both copies of a repeated key stay. RFC 8259 says keys should be unique, and most parsers, JavaScript's included, keep only the last value, so rename or remove one of them.

Sources: IETF, RFC 8259: The JSON data interchange format

How do I minify JSON, and how is that different from formatting?

Paste the JSON and pick Minify, then copy the result or download minified.json. Format adds line breaks and 2-space indents so people can read it. Minify removes every space and line break outside strings, which makes the text smaller for an API request or storage. The data is the same either way.

How do I sort JSON keys alphabetically?

Tick Sort keys A to Z. The keys of every object, nested ones too, go in order; arrays keep their order, because in an array the order is the data. Keys compare by character code, the way JavaScript and jq --sort-keys sort them, so capitals come before lowercase: B before a. Sorting both sides first makes two JSON files easy to compare line by line.

Is it safe to paste API responses here?

Yes. Checking and formatting run in your browser and nothing is uploaded or saved. That makes it fine for responses that hold tokens, emails or customer records.