SmartKitio

Developer topics · Updated 2026-10-04

JSON Formatting and Validation: Complete Guide

JSON is a text format for structured data: objects, arrays, strings, numbers, booleans, and null. Formatting and validation are two sides of the same coin—if the text does not parse, it is not JSON yet, no matter how it looks.

What counts as JSON

  • Property names must be double-quoted strings.
  • Strings use double quotes, not single quotes.
  • No comments and no trailing commas.
  • Numbers are base-10 decimals (no leading zeros as octal, no NaN/Infinity in strict JSON).
  • A document is one value—usually an object or array—not multiple top-level values.

Formatting (pretty-print)

A formatter parses the text into a value, then prints it again with consistent indentation and spacing. That process normalizes insignificant whitespace. Duplicate keys keep the last value the parser retained.

output = JSON.stringify(JSON.parse(input), null, 2)

Validation

Validation is the parse step alone: either the text becomes a value, or the parser raises an error. A separate “validator” tool is useful when you want a clear pass/fail without rewriting the document.

How SmartKitio’s tools behave

  • The JSON Formatter pretty-prints with two-space indentation or minifies to one line.
  • Parse errors surface the browser’s JSON error message so you can locate the problem.
  • Only strict JSON is accepted—not JSON5, not JSON Lines as a whole file.
  • Parsing and formatting run locally in your browser; the payload is not uploaded to SmartKitio for processing.
  • Integers beyond JavaScript’s safe integer range lose precision because they are read as IEEE-754 numbers—send large IDs as strings when that matters.

Common mistakes

Frequent JSON parse issues

SymptomLikely cause
Unexpected token 'Single-quoted string or property
Unexpected token /Comment (// or /* */)
Unexpected token }Trailing comma before closing brace
Unexpected end of JSONTruncated paste or incomplete bracket

Try these SmartKitio tools

Use a tool when you want a result; keep this guide open when you want the method.

Browse family: Developer Tools

Related articles

Broader reading that connects to this guide—when the topic deserves more than a how-to.

Related guides