JSON Formatter & Validator

Format, validate, minify, and automatically fix common JSON errors instantly in your browser. Includes a line-numbered editor, detailed error messages with helpful hints, and JSON statistics. Free, fast, and private — your JSON never leaves your device.

All formatting happens locally in your browser. Your JSON is never uploaded.
Input
Output

How the JSON Formatter works

This tool processes JSON entirely in your browser using the native JavaScript JSON.parse() and JSON.stringify() APIs. Nothing is ever transmitted to a server.

Parsing and validation

When you click Format, Validate, or Minify, the tool calls JSON.parse() on your input text. If parsing succeeds, the JSON is structurally valid. If it fails, the browser's JavaScript engine returns a SyntaxError with a message that includes the approximate location of the problem — the tool extracts the line and column number from that message and displays it alongside the error.

Pretty printing

Formatting calls JSON.stringify(parsed, null, 2), which serialises the parsed value back to text with 2-space indentation. This is the standard approach — it normalises irregular whitespace and ensures consistent output.

Minification

Minification calls JSON.stringify(parsed) without an indentation argument. This produces the most compact valid JSON — no spaces after colons or commas, no newlines. The data is identical; only whitespace is removed.

Browser-only processing

No data leaves your browser tab. You can disconnect from the internet after loading the page and the tool will continue to work. The source code is visible in your browser's developer tools under the Sources panel.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format specified in RFC 8259. Despite its name, JSON is language-independent and is used across virtually every programming language and platform.

Where JSON is used

  • REST APIs — the dominant response format for web services
  • Configuration files — package.json, tsconfig.json, .eslintrc, and more
  • Log data — structured logging in cloud and application platforms
  • Data exchange — between frontend and backend applications
  • NoSQL databases — MongoDB, CouchDB, and DynamoDB store JSON natively
  • Structured data / SEO — JSON-LD for schema.org markup in HTML

JSON data types

  • Object — unordered set of key/value pairs: {"key": "value"}
  • Array — ordered list of values: [1, 2, 3]
  • String — double-quoted text: "hello"
  • Number — integer or float: 42, 3.14
  • Booleantrue or false
  • Null — the absence of a value: null

Important: JSON is not a superset of JavaScript. JSON strings must use double quotes (not single quotes), keys must be quoted, trailing commas are not allowed, and comments are not supported.

Why format JSON?

Raw JSON from APIs and databases is often minified — a single long line with no whitespace. While compact, it is almost impossible for a human to read and debug. Formatting makes the structure immediately visible.

Common use cases

  • API debugging — reading raw API responses from curl or Postman
  • Configuration review — understanding complex nested configs
  • Log analysis — parsing structured log output
  • Code review — reviewing JSON fixtures in pull requests
  • Client communication — sharing readable data with non-developers
  • Schema inspection — understanding API response structures

When to minify

  • Production APIs — reduce response payload size and transfer time
  • Storage — reduce file size when storing large JSON documents
  • Embedding in HTML — compact JSON-LD in <script> tags
  • URL encoding — shorter JSON is easier to pass in query parameters
  • Build pipelines — minify config files before deployment

Who should use this tool?

Any technical professional who works with data, APIs, or configuration files will find a JSON formatter useful on a regular basis.

  • Developers — debug API responses, inspect webhook payloads, and review data structures
  • IT admins and sysadmins — read cloud configuration files, Azure and AWS policy documents, and structured logs
  • MSPs and managed service teams — troubleshoot vendor APIs and review client configuration exports
  • Security engineers — inspect JSON Web Tokens, API responses from security tools, and SIEM data
  • DevOps engineers — work with Kubernetes manifests, Terraform JSON configs, and CI/CD pipeline configs
  • QA testers — validate API test fixtures, compare expected vs. actual JSON responses

Privacy

All JSON processing happens entirely in your browser. When you paste JSON into the tool, your data is handled exclusively by JavaScript running in your browser tab — it is never transmitted to any server, never logged, and never stored anywhere outside your device.

This is especially important when working with sensitive data: API keys in configuration files, authentication tokens, personally identifiable information in API responses, or internal application data. You can safely use this tool with sensitive JSON without any risk of that data being captured or stored externally.

Technical verification: Open your browser's developer tools (F12), select the Network tab, and use the formatter. You will see zero outgoing requests triggered by the Format, Validate, or Minify buttons. The tool works entirely through in-memory JavaScript execution.

Frequently asked questions

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. It is easy for humans to read and write, and easy for machines to parse and generate. JSON is built on two structures: a collection of name/value pairs (objects, written as {"key": "value"}) and an ordered list of values (arrays, written as [1, 2, 3]). Despite its name, JSON is language-independent and is used by virtually every programming language and platform.

What does a JSON formatter do?

A JSON formatter (also called a JSON pretty printer) takes compact or irregularly indented JSON and rewrites it with consistent indentation — typically 2 or 4 spaces per level. The result shows each key-value pair on its own line with nested structures visually indented, making the hierarchy immediately readable. Formatted JSON is functionally identical to the original — only whitespace is added.

Is my JSON data uploaded to any server?

No. All formatting, validation, and minification happens entirely in your browser using the JavaScript JSON.parse() and JSON.stringify() APIs. Your JSON data is never sent to any server, never logged, and never stored anywhere outside your own browser tab. You can verify this by opening your browser's Network tab in developer tools while using the tool — you will see no outgoing requests.

How do I validate JSON?

Paste your JSON into the input area and click Validate JSON. The tool attempts to parse the text and reports whether it is structurally valid. If invalid, it shows the error message along with the approximate line and column number where parsing failed. You can also use Format JSON — if it succeeds, the JSON is valid. The tool also runs live validation as you type, updating the status indicator automatically.

What is JSON minification?

JSON minification removes all unnecessary whitespace — spaces, tabs, and newlines — from JSON text without changing its data. Minified JSON is functionally identical to formatted JSON but takes fewer bytes, reducing file size and speeding up data transfer over networks. It is commonly used in production API responses and when embedding JSON in HTML documents where every byte matters.

Why is my JSON invalid?

The most common causes of invalid JSON are:

  • Trailing commas{"a": 1,} is invalid JSON (valid in JavaScript)
  • Single quotes — JSON requires double quotes for all strings and keys
  • Unquoted keys{a: 1} is not valid JSON
  • Comments — JSON does not support // or /* */ comments
  • Mismatched brackets — unclosed {, [, or "
  • Missing commas — between items in an array or object
  • Invalid valuesundefined, NaN, and Infinity are not valid JSON
What causes JSON parsing errors?

JSON parsing errors occur when the text does not conform to the JSON specification. The error message will name the unexpected token and its position. Common messages:

  • Unexpected token } in JSON at position N — often a trailing comma
  • Unexpected token ' in JSON at position N — single-quoted string
  • Unexpected token u in JSON at position Nundefined value
  • Unexpected end of JSON input — missing closing bracket or quote
Can I format large JSON files?

Yes. Files up to a few megabytes format instantly. Very large files (tens of megabytes) may take a few seconds and could temporarily slow the page. The tool has no file size limit, but browser memory constrains practical use. For files over 10 MB, command-line tools are more efficient:

  • jq . file.json — using the jq command-line tool
  • python -m json.tool file.json — using Python's built-in module
  • cat file.json | python3 -m json.tool — pipe version
Does formatting change my data?

No. Formatting only adds whitespace — it does not change keys, values, types, or structure. Minification also preserves all data. The only edge case is that JSON.parse and JSON.stringify may normalize certain JavaScript behaviors, such as rounding floating-point numbers with excessive precision or reordering object keys in some engines. For standard JSON data, all values will be preserved exactly.

Is this JSON formatter free?

Yes, completely free. No sign-up, no account, no API key, no rate limits, and no data is ever sent to any server. It is a free public utility provided by SwissArmyTechTools for developers, IT admins, sysadmins, and anyone who works with JSON.

Can this tool automatically fix invalid JSON?

Yes. Click Format JSON — if the JSON is invalid, the tool first attempts a safe, automatic repair before formatting. It can remove leading, trailing, and dangling commas, convert smart/curly quotes and single-quoted strings or keys to standard double quotes, strip JavaScript-style comments, add double quotes around unquoted property names, remove extra closing }/], add missing closing }/], strip a UTF-8 byte order mark (BOM), and trim stray whitespace. If a repair is applied, the result is pretty-printed and a summary of what was fixed is shown above the editor. The tool only applies a fix if the result is valid JSON afterward — it never guesses at missing commas or values, since that could change the meaning of your data. If the JSON cannot be safely repaired, your input is preserved and the tool highlights the exact line and column of the problem with a plain-English explanation.