JSON Formatter

Paste JSON to format, validate and explore it. Fix broken JSON in one click, check it against a JSON Schema, search it as a tree or table, query it with JSONPath, compare two files, generate code in 12 languages and convert to YAML, CSV, SQL, XML and more. Your data stays in your browser.

InputEmpty
Result
Ctrl+Enter formatAlt+M minifyAlt+F auto-fixAlt+Q query

Everything runs in your browser. Nothing you paste is uploaded.

What is a JSON formatter?

JSON is the text format that most web APIs, apps and config files use to store data. When it arrives as one long line it is almost impossible to read. A JSON formatter, also called a beautifier or pretty printer, adds line breaks and indentation, and a validator checks that the syntax is correct. This tool does both at once, and goes further.

What you can do here

Check: live validation with the exact line and column of a mistake, a plain-English hint and a code frame, plus validation against a JSON Schema. Fix: Auto-fix repairs comments, single quotes, unquoted keys, trailing or missing commas, Python values, NaN and missing brackets, and lists every change. Explore: a collapsible tree with search and copy-path, a sortable table for lists of objects, and statistics that show the heaviest parts of your data and the most used keys. Query: JSONPath with filters, slices and wildcards. Compare: a path-by-path diff of two documents, and RFC 6902 JSON Patch.

Generate code: TypeScript, Zod, Python, Pydantic, Go, Java, C#, Kotlin, Rust, Swift, PHP and GraphQL types from your data. Convert: JSON to YAML, XML, TOML, CSV, TSV, JSON Lines, Markdown and HTML tables, SQL, .env and .properties, and CSV, XML, YAML, Base64 or a JWT back to JSON. Lab: sort, group and total lists, rename or remove keys, find and replace, make realistic mock data, and redact passwords, tokens and emails. Clean: sort keys, remove nulls and empties, turn Unix times into dates, convert text numbers to real numbers, flatten or unflatten, escape or unescape.

Exact numbers and key order

Many tools quietly change your data. This one keeps numbers exactly as typed, so long IDs such as 12345678901234567890 are never rounded, and it keeps the order of your keys unless you choose to sort them. Duplicate keys are reported instead of silently dropped.

How to use it

  1. Paste, open or drop your JSON into the input box.
  2. Check the status above the box. If it is not valid, click Go to error, or press Auto-fix.
  3. Choose a result: Format, Minify, a Transform or a Convert option. Switch between Code, Tree, Table and Stats.
  4. Copy or download the result, or press the arrow to use it as the new input.

Frequently asked questions

What does a JSON formatter do?

It takes JSON that is hard to read, such as one long line, and lays it out with line breaks and indentation so you can read and check it. It also validates the JSON and tells you the exact line and column of any mistake.

How do I validate JSON?

Paste it into the input box. The status chip shows Valid JSON or Invalid JSON with the line and column of the first error, a short hint and a Go to error button. Validation runs as you type.

Can it fix broken JSON automatically?

Yes. Auto-fix repairs common problems: comments, single quotes, unquoted keys, trailing commas, missing commas, Python True, False and None, NaN, code fences and missing closing brackets. It lists what it changed, and you choose whether to use the fixed version.

Is my JSON uploaded to a server?

No. Everything runs in your browser. Your data is not sent anywhere. If auto-save is on it is kept only in this browser's local storage, and you can turn that off in Settings.

How do I validate JSON against a JSON Schema?

Open Schema, paste your schema, and the input is checked as you type. Each problem shows its path and a plain message, and clicking it jumps to that spot in the Tree. You can also generate a schema from your data, or generate sample data from a schema.

Can it generate code from JSON?

Yes. The Code menu builds TypeScript interfaces, Zod schemas, JSON Schema, Python dataclasses, Pydantic models, Go structs, Java, C#, Kotlin, Rust serde, Swift Codable, PHP classes and GraphQL types from your data. Missing keys become optional fields and mixed numbers become the wider type.

Can I convert JSON to CSV, YAML, XML, SQL or TOML?

Yes. The Convert menu turns JSON into YAML, XML, TOML, CSV, TSV, JSON Lines, a URL query string, a Markdown or HTML table, SQL CREATE TABLE and INSERT statements, a .env file or a .properties file. You can also paste CSV, XML or YAML and convert it to JSON.

How do I query JSON with JSONPath?

Open Query and type an expression such as $.items[*].title or $..price. You can use filters like $.items[?(@.price>10)], slices like [0:3] and the .length helper. Matches are shown as a JSON list.

Can I compare two JSON files or create a JSON Patch?

Yes. Compare shows what was added, removed or changed with the exact path of each difference, and key order is ignored. In the Lab you can create an RFC 6902 JSON Patch or an RFC 7386 Merge Patch between two documents, or apply one to your data.

What can the Lab do?

Array tools (sort, remove duplicates, group, count, sum, average, median), editing (set or delete a path, rename keys to camelCase or snake_case, remove keys, find and replace), a mock data generator that makes realistic names, emails, dates and prices, JSON Patch, and a redactor that hides passwords, tokens, emails and card numbers.

Can it decode a JWT?

Yes. Paste a token in the input box and choose Convert, JWT to decoded JSON. You see the header, payload and expiry time. The signature is not verified, because that needs a secret key.

Does it keep big numbers exact?

Yes for format, minify, tree, table and conversions. Numbers are kept as the exact digits you typed, so long IDs are not rounded. The Stats tab warns you about numbers that other tools, such as JavaScript, may round. A few Lab tools work on plain values and show a note when your data has such numbers.

How large a JSON file can it handle?

Several megabytes work well. Files around 5 MB format in about a second on a normal computer. Very large files switch off syntax colours and show the tree in small chunks to stay fast.