{}

JSON Formatter

Paste your JSON below to format, validate and make it easier to read. This tool runs in your browser and does not upload your input.

Updated July 11, 2026

100% Private & Secure

This tool runs in your browser.
Your data is never uploaded or stored.

1
1
Click Format or Minify to see results

How to use

  1. 1

    Paste your JSON into the input box.

  2. 2

    Click Format to beautify and validate it.

  3. 3

    Copy the formatted output when you are done.

When to use it

Debugging a failing API request

When a fetch returns something unexpected, paste the raw response body and format it. The indented tree makes it obvious which field is missing, mistyped, or nested one level too deep.

Reading minified or single-line config

Files like package-lock.json, Terraform state, or a one-line API payload are unreadable as-is. Formatting turns them into navigable, structured output you can actually scan.

Validating before a deploy

Catching a stray trailing comma or unquoted key locally is far cheaper than discovering it when your config loader throws in production.

Sharing snippets in reviews and docs

Consistently indented JSON reads cleanly in pull requests, READMEs, and bug reports — and copy-pastes without reflowing.

How it works

What JSON actually is

JSON (JavaScript Object Notation) is a text interchange format defined by RFC 8259. It has exactly six data types: object, array, string, number, boolean, and null. Despite the name, JSON is not a subset of JavaScript syntax — it is its own, stricter grammar.

Strings must use double quotes; object keys must be quoted; there are no comments, no trailing commas, and no bare NaN or Infinity. That strictness is the point: any compliant parser, in any language, reads the same bytes the same way.

  • {} object and [] array — named and ordered collections
  • Numbers are IEEE 754 double precision — integers lose precision past 253
  • true, false, and null are the only literals

Valid JSON is not always valid JavaScript

A common trap: text that runs fine in a .js file makes JSON.parse throw. The three usual suspects are single-quoted strings, unquoted keys, and trailing commas — all legal JavaScript, all illegal JSON.

There is also the subtler U+2028 / U+2029 case: these line separators are valid inside JSON strings but were invalid in JavaScript string literals before ES2019. This is why you should never eval() JSON — always parse it.

// Valid JavaScript, INVALID JSON — JSON.parse throws on all three:
{ 'key': 'value', }   // single quotes + trailing comma
{ key: "value" }      // unquoted key

How pretty-printing works under the hood

Indentation comes from JSON.stringify(value, replacer, space). The third argument controls spacing — pass 2 for two spaces, or "\t" for tabs. The second argument is a replacer: a function to filter or transform values, or an array of keys to whitelist.

For very large payloads (multi-megabyte logs), formatting has a real memory cost because the entire structure is serialized into a new string. Validate first, format second, and reach for a streaming parser when input is huge.

Common mistakes & edge cases

Problem

"Unexpected token } in JSON" or trailing characters after the document

Fix

Almost always a trailing comma after the last item. JSON forbids trailing commas — remove it.

Problem

"Unexpected token ' in JSON" — strings wrapped in single quotes

Fix

JSON requires double-quoted strings. Switch every ' to " on both keys and values.

Problem

"Unexpected token k in JSON" — an unquoted object key

Fix

Keys must be double-quoted. { name: "x" } is JavaScript; { "name": "x" } is JSON.

Problem

// or /* */ comments cause a parse error

Fix

Plain JSON has no comments. If you need them, use JSONC or JSON5 — but standard JSON.parse will reject them.

Frequently Asked Questions

Is my JSON uploaded to a server?
No. This tool runs in your browser, so your JSON is processed locally.
Can this tool validate invalid JSON?
Yes. If your JSON is invalid, the tool will show an error message.
What is JSON formatting?
JSON formatting adds indentation and line breaks to make JSON easier to read.

References & further reading

Related reading

Related Tools

View all tools