arrow_backBack to Guides
Sep 15, 2026·Formatting

Formatting and Linting JSON Web Tokens

The Messy Reality of Real-World Tokens

In theoretical tutorials, a JWT is a pristine, continuous string of alphanumeric characters. In the real world, working with tokens is incredibly messy. When you copy a token from a browser's network tab, extract it from a server's logging system, or receive it from a colleague over Slack, it rarely arrives in a clean format.

Common Formatting Contaminants

Before you can successfully parse or validate a token programmatically, you almost always have to sanitize the string. The most common contaminants include:

  • The Bearer Prefix: Because JWTs are transmitted in the HTTP Authorization header, they are almost always prefixed with the word Bearer . If you attempt to feed the string Bearer eyJhb... directly into a JWT parsing library, it will fail violently. The prefix must be stripped.
  • Whitespace and Newlines: Copy-pasting from terminal windows or IDEs frequently introduces hidden spaces, tab characters, or line breaks into the middle of the token string. Because Base64URL cannot contain whitespace, the token immediately becomes invalid.
  • JSON Escaping: Sometimes tokens are embedded deeply inside larger JSON responses. When extracted, they might still be wrapped in quotation marks, or contain escaped slashes (\/) from poor serialization practices.

The Importance of Payload Formatting

Once you actually manage to sanitize the token string and decode the Base64URL payload, you are presented with a dense, minified JSON object. For a machine, this is fine. For a human developer trying to debug a missing claim, reading minified JSON is a nightmare.

How TokenDecode Solves This

This is exactly why we built the Token Formatter tool. It acts as an intelligent sanitizer. You can paste in the ugliest, messiest token string imaginable—complete with "Bearer" prefixes, weird line breaks, and random quotes—and the tool will automatically strip the garbage, identify the three JWT segments, and format the underlying JSON into a beautiful, nicely-indented, syntax-highlighted structure.