3tej home
← Utilities

What is JSON Formatter / Validator?

A JSON Formatter / Validator reformats your input for readability without changing its meaning. It parses the source, applies consistent indentation, spacing and casing, and returns a clean copy you can paste back into your project. Developers use it when debugging APIs and preparing data files.

JSON Formatter / Validator

Pretty-print, minify, validate. With error line/column. Runs entirely in your browser.

JSON Formatter

Paste any JSON to pretty-print or validate. Errors show the position reported by JSON.parse.

Status-
Formatted output
-
How does this work?

Uses the browser's native JSON.parse to validate, then JSON.stringify(value, null, indent) to pretty-print. Errors are reported by the engine and include the position when available. Source: ECMA-404 JSON spec.

About this JSON formatter and validator

JSON (JavaScript Object Notation) is the most common wire format on the modern web. It is defined by RFC 8259 (IETF, 2017) and ECMA-404 (ECMA, second edition 2017), which agree on six value types (object, array, string, number, boolean, null) and a strict whitespace grammar. This page calls the browser's native JSON.parse to validate, then JSON.stringify(value, null, indent) to pretty-print or re-emit minified. Validation errors include the position the engine reports so you can jump to the offending byte.

Pretty-printing matters because minified JSON is unreadable: a 12-key object collapses to one 600-character line with no indentation, no key alignment, no rule boundaries. After formatting, the same object spans 14 lines with a two-space indent and nested objects visibly recurse one level deeper per {. The output parses identically; only whitespace changed.

How the formatter works

The validator and formatter are a thin shell over JSON.parse and JSON.stringify, both shipped natively in every browser since Internet Explorer 8.

try {
  const value = JSON.parse(input);                  // throws SyntaxError on invalid input
  const pretty = JSON.stringify(value, null, 2);    // two-space indent
  const min    = JSON.stringify(value);             // minified, no whitespace
} catch (err) {
  // err.message includes the position: 'Unexpected token } in JSON at position 47'
}

The engine's parser is a strict RFC 8259 implementation: trailing commas, single quotes, unquoted keys, comments, and bareword identifiers all fail. The error message tells you the byte offset of the first invalid character so a simple input.slice(0, position) walks straight to the bug.

Worked example: validating and pretty-printing

Suppose you paste this minified API response (89 bytes):

{"user":{"id":42,"name":"Ada","roles":["admin","editor"],"verified":true,"score":3.14}}

The validator confirms 'Valid JSON' and the formatter emits (162 bytes):

{
  "user": {
    "id": 42,
    "name": "Ada",
    "roles": [
      "admin",
      "editor"
    ],
    "verified": true,
    "score": 3.14
  }
}
Output is 82 percent larger but readable. Each key is on its own line, nested objects indent two spaces deeper, arrays of primitives also one element per line. Pasting it back into the formatter and pressing Minify reproduces the original 89 bytes exactly.

JSON value types reference

JSON quick reference

JSON (JavaScript Object Notation) is a text data format defined by ECMA-404 and RFC 8259. It supports six value types and is the default wire format for most modern APIs.

TypeExampleNotes
object{"a": 1}Unordered key-value pairs. Keys must be quoted strings.
array[1, 2, 3]Ordered list. Heterogeneous types allowed.
string"hello"Always double-quoted. Escape sequences match JS.
number42, -3.14, 6.022e23No NaN, Infinity, or BigInt. Just IEEE 754 double.
booleantrue, falseLowercase only.
nullnullLowercase. Distinct from absent / undefined.

JSON vs JSON5 vs JSONC vs YAML

FormatComments?Trailing commas?Unquoted keys?Best for
JSON (strict)NoNoNoAPIs, machine-to-machine
JSON5YesYesYesConfig files (VS Code, .babelrc)
JSONCYesYesNoVS Code settings, tsconfig.json
YAMLYesYesYes (mostly)CI configs, Kubernetes manifests

Common mistakes

  • Trailing commas - JSON forbids them. {"a": 1,} is invalid. JavaScript object literals allow them; JSON doesn't.
  • Single quotes - JSON requires double quotes. {'a': 1} is invalid.
  • Unquoted keys - keys must be quoted strings, even if they look like identifiers.
  • NaN, Infinity, undefined - none of these are valid JSON values. Most parsers reject them.
  • BigInt - JSON numbers are IEEE 754 doubles. Integers above 2^53 - 1 (~9 quadrillion) lose precision. Use strings for IDs from Twitter, Discord, Snowflake-based systems.
  • Date handling - JSON has no date type. The convention is ISO 8601 strings: "2026-05-13T12:00:00Z". JSON.parse won't auto-parse them; you must convert.

Frequently asked questions

Is my data safe?

Yes. Uses browser-native JSON.parse/stringify. No server calls.

Why do I get 'Unexpected token' when parsing?

Most common causes: trailing comma, single quotes, unquoted key, or a Windows BOM (\uFEFF) at the start of the file. Open the source in a hex editor or use JSON.parse(text.trim().replace(/^\uFEFF/, '')).

How big can a JSON document be?

No formal limit. Practical limit is your parser's memory. JSON.parse in Node handles ~512 MB before failing on most systems. For larger documents, use a streaming parser (oboe, JSONStream).

Can JSON contain comments?

No - the standard forbids them. Many tools accept JSONC or JSON5 as supersets. For pure JSON, strip comments before parsing or store them as _comment fields.

Why are numbers like 0.1 + 0.2 not 0.3 in JSON?

JSON numbers are IEEE 754 doubles. 0.1 + 0.2 = 0.30000000000000004 in any IEEE-754 system. Use strings if exact decimal arithmetic matters (currency, etc.).

Is JSON case-sensitive?

Yes - both keys and string values. {"a": 1} and {"A": 1} are distinct.

How accurate is the JSON Formatter / Validator?

It applies the standard formula. Accuracy is limited only by your input precision. For decisions with material consequences (taxes, medical, legal, structural), use the result as a starting point and verify with a qualified professional in the relevant field.

Is the JSON Formatter / Validator free to use?

Yes. 100% free, no signup, no payment, no API key. The site is funded by display ads around the tool but not inside the calculation flow.

Are my inputs saved anywhere?

No. All inputs stay in your browser tab. Closing the tab discards them. The site uses Google Analytics for traffic measurement (anonymized) but the analytics never see what you type into the form.

Can I use the JSON Formatter / Validator on my phone?

Yes. The tool is responsive and tested on iOS Safari, Android Chrome, and major desktop browsers. Touch targets meet Apple's 44pt and Google's 48dp minimum.

Does the JSON Formatter / Validator work offline?

Yes. Once the page has loaded, it works without internet. The calculation runs in JavaScript on your device.

How do I report a bug or suggest improvement to the JSON Formatter / Validator?

Email hi@3tej.com with the URL of this page and a description of what you saw vs expected. We typically respond within 72 hours.

Can I share results from the JSON Formatter / Validator?

Take a screenshot or copy the output. The page doesn't generate shareable URLs for specific calculations - inputs stay in your browser only.

Why are the results different from another json formatter / validator tool?

Most likely: different formula assumptions, different default values, different rounding rules, or different applicable rates. Check the methodology if both tools document it. Both can be valid for different scenarios.

IT
India Tools Editorial
Calculators & explainers maintained by the India Tools team.