Skip to content
Mike RotichPERSONAL PORTFOLIOSearch Ctrl KWorkspace ↗

PRACTICAL GUIDE / PROGRAMMING

Validate JSON before using it

Learn the difference between valid syntax and valid data.

ROTICH learning material · 1 minute read

A small example

JSON is a data format. Object keys and strings use double quotes, and trailing commas are not allowed. Paste the example into the formatter.

Make a deliberate mistake

Remove a closing brace and run the formatter. The parser should reject the document rather than silently repair it. Restore the brace to continue.

Validation has two layers

Parsing checks syntax. Your application must still validate meaning: whether a name is present, an amount is within range and a property has the expected type. Valid JSON does not automatically make an input trustworthy.

Compare safely

Use the JSON comparison tool to compare two versions. The result identifies changed paths. These browser utilities do not upload your input, but avoid pasting secrets into any shared screen or demonstration.

Example input

{
  "project": "Example",
  "values": [2, 4, 6],
  "active": true
}

Try the exercise ↗

← Learning resources

Public content only. Tab through results; Esc closes search.