Format, validate and minify JSON

Paste your JSON and pick an action. Everything runs in your browser.

Local only0 bytes uploaded

Ctrl/⌘ + Enter beautifies

Input

Waiting for input

Result

Result appears here

What this tool does

json.foo takes any JSON text and does four things with it, all on your own device:

Validate
Checks the input as you type. The line under the editor says Valid JSON with the size and line count, or repeats the parser's message so you can find the problem.
Beautify
Re-indents the document with four spaces and one key per line: the shape you want when you read an API response or review a config file.
Minify
Removes every space and line break outside strings. Same data, fewer bytes, ready for a request body, an environment variable or a test fixture.
Escape
Turns the whole input into one JSON string literal: quotes become \" and line breaks become \n. Use it to put JSON inside another JSON document, a source file or a shell command.

How to use it

  1. Paste JSON into the Input editor, or use Open file (up to 20 MB), From URL or Sample.
  2. Read the status line under the editor. If the JSON is invalid, it tells you what the parser expected and where it stopped.
  3. Press Beautify (or Ctrl/⌘ + Enter), Minify or Escape.
  4. Copy the result with the Copy button. The input is never changed, so you can try all three actions on it.

What the validator catches

The validator uses your browser's own JSON parser, the same one behind JSON.parse in your JavaScript code. If a document passes here, it parses in production. It follows the JSON standard (RFC 8259) strictly, so things that JavaScript, Python or YAML accept are rejected:

  • trailing commas, as in [1, 2,]
  • single quotes, as in {'name': 'Ana'}
  • keys without quotes, as in {name: "Ana"}
  • comments, both // and /* */
  • NaN, Infinity and undefined
  • numbers with leading zeros (007) or in hex (0xFF)
  • raw line breaks and tabs inside strings

Each of these has an example and a fix in Common JSON errors and how to fix them. The wording of the message depends on your browser: Chrome reports a character position, Firefox a line and column.

Before you trust the output

Beautify and Minify parse your JSON and write it back out. For almost every document that is lossless, but JavaScript's parser has four habits worth knowing:

Big integers
Numbers are stored as 64-bit floats, so integers above 253 (9,007,199,254,740,991) get rounded: 9007199254740993 comes back as 9007199254740992. If your payload carries 64-bit IDs as numbers, check them, or send them as strings.
Duplicate keys
{"a": 1, "a": 2} becomes {"a": 2}. The last value wins and the validator does not warn you.
Key order
Keys keep their order, except keys that look like whole numbers ("2", "10"), which move to the front in ascending order. It only matters if you diff the result against the original.
Number spelling
1.0 becomes 1 and 1e3 becomes 1000. The values are equal; the text is not.

Escape does not parse anything, so it never changes your content. It only wraps it.

Where your data goes

Nowhere. The page loads once, and from then on validation, formatting and conversion happen in JavaScript on your device. There is no server endpoint that receives your JSON; you can open the network tab of your browser's developer tools and check.

From URL is the only feature that makes a request, and it goes straight from your browser to the address you type. The details, including how ads work on this site, are in the privacy policy.

Need typed models instead?

Paste the same payload into the JSON converter to generate Java, Kotlin, TypeScript, Python, Go, C# or Rust types from it.

New to the format, or fighting an error you do not recognise? Start with the JSON syntax rules or the guide to escaping JSON strings.

Load JSON from a URL

The server must allow cross-origin requests (CORS).