Developer Workflows

Format, Minify, and Base64-Encode JSON Privately

The three JSON jobs every API developer does weekly, done in the right order, without pasting production payloads into someone else’s website.

Most JSON handling is not glamorous. A webhook body arrives as one enormous line and you need to read it. A config value has to be squeezed onto a single line. Some API wants the whole payload Base64-encoded inside another JSON field. None of this is hard, but doing it in the wrong order produces errors that waste an hour.

The other problem is where people do it. The quickest route is usually to search "json formatter" and paste into the first result. That payload might contain customer emails, access tokens, or internal IDs. You do not need to send any of that anywhere to add some indentation.

Format first, then minify, then encode

The order matters because each step makes the next one harder to debug.

  1. Format and validate. Paste the JSON into JSON Formatter. If it is valid, you get readable indentation and a tree view. If it is not, you get the line and position of the problem. This is the only step where mistakes are easy to see, so fix everything here.
  2. Minify. Once it is valid and correct, run it through JSON Minifier to strip whitespace. Use this for request bodies, environment variables, or anything with a size limit.
  3. Encode. Only if the destination actually requires it, encode the minified text with Base64 Encoder.

If you minify broken JSON, you now have broken JSON on one line, which is much harder to read. If you Base64-encode it, the error is invisible until the receiving service rejects it with an unhelpful message.

The errors you will actually hit

Nearly every "invalid JSON" message comes from a short list:

  • Trailing commas. JavaScript allows {"a": 1,}. JSON does not.
  • Single quotes. Keys and strings must use double quotes. Copying from Python output often gives you single quotes.
  • Comments. Standard JSON has no comments. Files like tsconfig.json tolerate them, but most parsers will not.
  • Unescaped characters. A raw line break or tab inside a string must be written as \n or \t.
  • Smart quotes. Pasting through a word processor or chat app can turn straight quotes into curly ones, which parsers reject.

A formatter that points to the exact position turns each of these into a ten-second fix.

When Base64 is the right call, and when it is not

Base64 turns bytes into plain letters, digits, and a couple of symbols so they can travel through systems that only handle text. Legitimate reasons to use it with JSON include HTTP headers that cannot contain braces and quotes, data fields inside another JSON document, and some queue or secret-store formats.

Two things people get wrong. First, Base64 is not encryption. Anyone can decode it in a second, so it does nothing to protect a payload. Second, it makes data about a third larger. If you are only encoding because a tutorial did, check whether the API actually asks for it.

Watch for the URL-safe variant as well. Standard Base64 uses + and /, which cause trouble in URLs, so some systems (JWTs among them) use - and _ instead and drop the trailing = padding. If a decoder rejects your string, that mismatch is the first thing to check.

A quick worked example

Say a partner API wants a header called X-Context containing Base64-encoded JSON. You start with this, copied from a log:

{'user': 'u_1042', 'plan': 'team', 'features': ['export', 'sso',]}

The formatter flags it immediately: single quotes and a trailing comma. After fixing it:

{
  "user": "u_1042",
  "plan": "team",
  "features": ["export", "sso"]
}

Minified, that becomes {"user":"u_1042","plan":"team","features":["export","sso"]}, and encoding it gives you a single string you can drop into the header. If the partner rejects it, decode it with Base64 Decoder to confirm it round-trips before blaming their side.

Habits that keep payloads private

  • Use tools that run in your browser for anything copied from production.
  • Before sharing a sample with a colleague or vendor, replace real values. Keep the structure, change the data.
  • Do not paste full tokens or API keys into tickets or chat, even Base64-encoded ones.
  • If you repeat the same three steps daily, save them as a chain in Recipe Studio so they run together.

Frequently asked questions

Does minifying JSON change the data?

No. Minifying only removes whitespace between tokens. Keys, values, and order stay the same, so any parser reads the minified version exactly like the formatted one.

Is Base64-encoded JSON secure?

No. Base64 is an encoding, not encryption. Anyone can decode it instantly. Use it for transport compatibility, never to hide sensitive values.

Why does my JSON work in JavaScript but fail validation?

JavaScript object literals allow single quotes, trailing commas, and unquoted keys. Strict JSON allows none of them. A validator shows exactly where the difference is.

Is my JSON sent to a server when I use these tools?

No. Formatting, minifying, and encoding all run in your browser. The text stays on your device.

Sources and further reading

← All posts Browse tools