XConvert
Downloads
Pricing

Format JSON Online

Upload or paste JSON to format it into clean, readable JSON and download the formatted result in seconds.

Input (JSON)
Output

How to Format JSON Online

  1. Paste or Upload Your JSON: Paste raw, minified, or partially-indented JSON into the Input (JSON) panel, or drag-and-drop a .json file onto the editor. The tool accepts any RFC 8259 valid JSON value — object, array, string, number, boolean, or null. Single-line API responses, escaped log entries, and multi-megabyte config files all work.
  2. Pick Indent: Choose 2 spaces (default; matches Prettier, npm, the JavaScript / TypeScript ecosystem), 4 spaces (Python json.dumps(..., indent=4), Java Jackson default, most government data feeds), or Tab (one tab per level — smaller bytes, configurable display width). Set Sort Keys if you want deterministic, diff-friendly output; leave it off to preserve insertion order.
  3. Format, Minify, or Validate: Click Format to pretty-print, Minify to strip every byte of optional whitespace, or Validate to run a parse-only pass that returns the exact error location on failure. The buttons are interchangeable — you can flip between formatted and minified output without re-pasting.
  4. Copy or Download: Click Copy to put the result on your clipboard, or Download to save a .json file. Everything runs in your browser via JSON.parse / JSON.stringify — no upload, no sign-up, no server log of your payload.

Why Format JSON?

JSON is wire-format by design: APIs, log pipelines, and config systems strip whitespace to save bytes, leaving you with a dense single-line string that is unreadable to humans. Pretty-printing adds line breaks after every key-value pair and array element, indents nested levels consistently, and aligns closing delimiters with their openers. The data is byte-for-byte equivalent — only the presentation changes — but the hierarchy becomes scannable. Common scenarios where this matters:

  • API response debugging — Pasting a raw Postman or curl body into the formatter exposes the nested structure of GraphQL or REST responses in seconds; missing fields, unexpected nulls, and wrong data types jump out instead of hiding inside a 4 KB single line.
  • Pull-request diffs — package.json, tsconfig.json, .eslintrc.json, app.json, and Terraform variable files all diff cleanly only when each property sits on its own line. Auto-formatting before commit is why Prettier ships JSON support out of the box.
  • Log forensics — Application logs from JSON-structured loggers (Winston, Bunyan, Python structlog, AWS CloudWatch) collapse events to single lines. Formatting one entry recovers the full event tree, including stack traces and request metadata.
  • Cloud configuration review — AWS CloudFormation, Azure ARM, GCP Deployment Manager, and Kubernetes manifests are often hand-edited as JSON. Reading a 600-line CFN template without indentation is impractical; formatting it before review surfaces logical blocks (Resources, Outputs, Parameters).
  • Documentation snippets — README examples and API docs render JSON examples in fenced code blocks where indentation is the only visual hierarchy available. Two-space indent is the unwritten standard here because it survives narrow code-block widths.
  • Schema authoring — JSON Schema, OpenAPI, and AsyncAPI documents are deeply nested. Formatting before working in them (and sorting keys for deterministic checksums) makes schema authoring and review tractable.

Format vs Minify vs Validate — Which One Do You Need?

Operation What it does Use when xconvert tool
Format Adds whitespace; preserves all data Reading, diffing, debugging, documentation This page
Minify Strips every optional space, tab, newline Embedding in URLs, API bodies, environment variables JSON Minifier
Validate Parses without re-emitting; returns error position Pre-flight check before sending to a strict consumer JSON Validator

Format and minify are reversible — pretty-print then minify and you get the same bytes you started with (assuming key order is preserved). Validate is read-only; it never modifies your input.

Indent Style Quick Guide

Indent Bytes per level Where it's idiomatic Notes
2 spaces 2 Prettier (default), npm package.json, React, Vue, Angular, Node.js core Most common in JavaScript / TypeScript projects; Prettier writes 2-space JSON regardless of tabWidth settings before v3
4 spaces 4 Python json.dump(..., indent=4), Jackson SerializationFeature.INDENT_OUTPUT, .NET JsonSerializerOptions { WriteIndented = true } Default in most non-JavaScript stdlibs; preferred for human-readable config and dataset publishing
Tab 1 byte (display width user-controlled) Some Go projects, older Java codebases, .editorconfig indent_style = tab shops Smallest byte cost; renders differently across editors — set explicit tabWidth if you need consistent diffs
No indent (minified) 0 Network payloads, JWT claims, URL parameters Use the Minifier; typical 20-40% size drop vs 2-space indent

Frequently Asked Questions

Is 2-space or 4-space indent better for JSON?

Two-space indent is the de-facto JavaScript ecosystem standard — it's what Prettier writes by default, what npm uses for package.json, and what the React / Vue / Angular toolchains expect. Four-space indent is the default for Python's json.dump(..., indent=4), Java's Jackson INDENT_OUTPUT, and most government open-data feeds. Pick what matches your toolchain and stay consistent across the project; mixing the two creates noisy diffs. For shared specs (OpenAPI, JSON Schema), 2 spaces is the more common convention.

Will formatting break my JSON?

No. JSON's whitespace rules in RFC 8259 treat spaces, tabs, line feeds, and carriage returns outside string literals as insignificant. The formatter parses your input with JSON.parse to build an in-memory tree, then re-emits it with JSON.stringify(value, null, indent). The round-trip is byte-equivalent for the data itself — only whitespace changes. Strings, numbers, escape sequences, and Unicode characters inside string values are preserved exactly.

Does the formatter sort keys alphabetically?

It can if you toggle Sort Keys. With sorting off, output preserves the input's key order. With sorting on, keys at every nesting level are sorted lexicographically by their UTF-16 code units. Sorting is useful for deterministic diffs (so a re-emit of the same logical object always produces identical bytes) and for hash-based caching, but it changes the visible order — be aware if downstream consumers iterate keys (most shouldn't, but some legacy systems do).

Does JSON preserve key order?

The JSON spec (RFC 8259, section 4) says objects are unordered name/value collections — order is technically not significant. In practice, since ES2015 (and ES2019's clarification of OrdinaryOwnPropertyKeys), V8, SpiderMonkey, and JavaScriptCore all preserve insertion order for non-integer string keys in objects, and JSON.stringify walks keys in that same order. Integer-like keys ("1", "2", "42") are sorted numerically first, which is why an object like {"2": "b", "1": "a"} re-emits as {"1": "a", "2": "b"} even without sort-keys enabled.

Format vs minify — which one should I ship to production?

Minify for the wire, format for the editor. Minified JSON is 20-40% smaller and faster to parse over the network, which is why APIs and JWT claim sets ship without whitespace. But check in formatted JSON to version control — Git diffs are line-oriented, and a one-line minified package.json makes every change show as a full-file rewrite. Most teams use a pre-commit hook (Prettier, lint-staged) to keep checked-in files formatted, then minify at build time or rely on HTTP gzip / brotli to do the size reduction automatically.

Can I format JSON with comments (JSONC / JSON5)?

Strict JSON does not allow comments — RFC 8259 omits them deliberately. JSON.parse rejects // and /* */. JSONC (VS Code's tsconfig.json dialect) and JSON5 add comments and trailing commas, but they are not valid JSON; this formatter will reject input that contains them. Strip comments first (regex /\/\/.*$|\/\*[\s\S]*?\*\//gm for most cases), or use a JSON5-aware tool. After formatting, you can re-add comments manually if you're targeting JSONC consumers.

How does this compare to VS Code's built-in Format Document?

VS Code uses the same JSON.parse + JSON.stringify round-trip under the hood (or Prettier if installed). The functional output is identical for valid JSON. The differences: VS Code requires opening the file in the editor and can struggle on documents past ~50 MB; this tool handles paste-and-go for an API response, runs offline after first load, and exposes a sort-keys toggle that VS Code's default JSON formatter does not. For batch processing, jq '.' file.json (pretty-print) or jq -c '.' file.json (minify) is faster.

Prettier vs jq — when to use which?

Prettier is a code formatter — it enforces opinionated style across JSON, JS, TS, CSS, Markdown, YAML, and more, and is best used inside an editor or pre-commit hook on tracked source files. jq is a JSON query and transform language; its . filter pretty-prints, but its real strength is filtering, mapping, and projecting fields (jq '.users[].email'). Use Prettier when you're keeping a file in sync with your project's code style; use jq when you're slicing a payload at the command line or scripting a transform. This web formatter sits between them — paste-and-go without installing anything, useful when you don't want to open an editor or write a jq expression.

What about NDJSON or JSON Lines?

NDJSON (also called JSON Lines, .ndjson, or .jsonl) puts one JSON value per line — streaming tools like Elasticsearch's bulk API, BigQuery loads, and jq --slurp use it. This formatter treats the entire input as a single JSON value, so it will fail on NDJSON. Either format each line individually, or convert to a JSON array first (jq -s '.') and then format the resulting array. For comparing two NDJSON files line-by-line, try Text Diff.

Is there a file-size limit?

There is no hard cap — everything happens in your browser. Performance is best on files under about 10 MB; larger inputs (up to ~100 MB) work but may pause the tab during parse. For very large files (hundreds of MB or more), use jq from the command line, or stream-process with a SAX-style parser like Python's ijson. No data ever leaves your machine, so even multi-megabyte payloads with credentials or PII stay private.

Image Tools

Image CompressorCompress JPEGCompress PNGCompress GIFCompress WebPImage ConverterJPG ConverterImage Resizer

Video Tools

Video CompressorCompress MP4MP4 to GIFVideo to GIFVideo ConverterMP4 ConverterVideo Cutter

Audio Tools

Audio CompressorCompress MP3Compress WAVAudio ConverterMP3 ConverterFLAC to MP3Audio Cutter

Document Tools

Compress PDFMerge Images to PDFSplit PDFPDF to JPGUnzip FilesRAR Extractor
© 2026 XConvert.com. All Rights Reserved.
About UsPrivacy PolicyTerms of ServiceContactHelp Us Grow