Skip to main content

Guides Β· Developer Tools Β· 3 min read

Formatting JSON the Safe Way

Every developer formats JSON daily: config files, API responses, log lines, webhook payloads. The mechanics take seconds; the risk management takes intention. Payloads routinely contain user data, tokens, and internal structure that should not be pasted into whatever site ranks first.

Filorra’s JSON formatter parses and pretty-prints entirely in your browser. This guide builds a workflow around that guarantee: validate locally, read structurally, and only then decide what may leave your machine.

Quick answer

Paste into a browser-local formatter, fix any reported syntax error (usually trailing commas or quote style), format to readable indentation, and inspect values before sharing anything onward.

Step by step: Formatting JSON the Safe Way

  1. Validate before formatting

    Run the formatter; if the JSON is invalid it reports the line and column of first confusion. Check immediately before that position for the usual culprits: trailing commas, single quotes, unquoted keys.

  2. Format with consistent indentation

    Choose two or four spaces per level and apply uniformly across your project. Consistency makes diffs meaningful; mixed indentation makes them noise.

  3. Read the structure, not just the syntax

    Formatted output exposes shape mistakes syntax hides: arrays where objects belong, duplicated keys silently overwriting, numbers quoted as strings. Scan top levels before trusting data.

  4. Redact before sharing

    When asking for help with a payload, replace secrets and personal data with placeholders first. Formatting tools being local means the redaction decision stays yours rather than happening in someone’s server logs by default.

Why local formatting matters more than it seems

JSON payloads are where applications keep their truth: session tokens in auth responses, customer records in CRM exports, infrastructure layouts in Terraform state. Pasting such text into a web formatter transmits it to an unknown operator whose logging you cannot inspect.

A browser-local formatter closes that channel entirely: parsing happens via JavaScript on your machine, and the network tab shows zero traffic. The convenience is identical; the trust model is fundamentally better.

Minification, sorting, and diffing as companions

The same tooling that prettifies can minify (strip whitespace for transport) and sort keys alphabetically. Sorted keys turn chaotic diffs into readable ones when configs change across branches.

For comparing two large JSON files, format both consistently first; structural differences then surface visually instead of hiding inside line noise.

Common mistakes

Fixing errors by deleting the reported line
Error positions point at where parsing broke, often after the actual typo. Inspect the preceding characters before removing anything.
Trusting valid JSON to be correct JSON
Syntax validity says nothing about schema correctness: wrong types, missing required fields, and duplicate keys all parse happily. Validate shape separately from syntax.
Editing generated JSON by hand at scale
For machine-written files (lockfiles, state), use generators and formatters as part of pipelines rather than hand edits that break checksums and ordering assumptions.

Privacy and security

Parsing, formatting, and validation run entirely in your browser; payloads never leave the tab.

No history of formatted documents is stored anywhere.

Frequently asked questions

Does formatting change my data?
Whitespace and key order aside, no: values, types, and nesting are preserved exactly. Note some consumers care about key order despite JSON semantics saying they should not.
How do I handle huge JSON files?
Browser memory comfortably handles tens of megabytes. For gigabyte-scale documents, use streaming command-line tools; interactive formatters are for human-sized payloads.
All questions β†’
All guides β†’
All articles β†’