Overview
The JWT node in n8n allows you to work with JSON Web Tokens (JWTs). In the context of the Default resource and Decode operation, this node decodes a JWT token and returns its payload. This is useful for extracting information from tokens received from authentication systems or APIs, without verifying their signature.
Common scenarios:
- Extracting user claims or metadata from a JWT provided by an external service.
- Debugging or inspecting the contents of a JWT during workflow development.
- Parsing tokens in automation flows where verification is not required.
Example:
You receive a JWT from an API response and want to extract the embedded user ID and roles for further processing in your workflow.
Properties
| Name | Type | Meaning |
|---|---|---|
| Token | String | The JWT token string to decode. |
| Return Complete Token | Boolean | If true, returns the full decoded token object (header, payload, etc.); if false, returns only the payload. |
Output
- json:
- If Return Complete Token is
false:
The output is the decoded payload of the JWT as a JSON object.
Example:{ "sub": "1234567890", "name": "John Doe", "iat": 1516239022 } - If Return Complete Token is
true:
The output is an object containing both the header and payload (and possibly signature) of the JWT.
Example:{ "header": { "alg": "HS256", "typ": "JWT" }, "payload": { "sub": "1234567890", "name": "John Doe", "iat": 1516239022 }, "signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" }
- If Return Complete Token is
Dependencies
- No external services or API keys are required for the Decode operation.
- The node uses the
jsonwebtokenlibrary internally. - No special n8n configuration is needed for decoding.
Troubleshooting
Common issues:
Malformed Token:
If the provided token is not a valid JWT, the node will throw an error such asInvalid token specified.
Resolution: Ensure the input token is a properly formatted JWT string.Empty Token:
If the Token property is left empty, the node may throw an error or returnnull.
Resolution: Always provide a non-empty JWT string.Unexpected Output Structure:
If "Return Complete Token" is enabled, the output structure changes.
Resolution: Adjust downstream nodes to handle the different output format.