> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/modularity/jwt/reference/built-in-functions/jwtdecode.md).

# JWTDecode

Decodes a JWS token **without verifying the signature**. Returns the header and payload so you can inspect the `kid`, `alg`, or any claim before deciding which key to verify with.

{% hint style="warning" %}
Never trust the contents returned by `jwtDecode()` for authorization decisions — always follow up with `jwtVerify()` (or `jwtValidate()`) before honoring any claim.
{% endhint %}

## Method Signature

```
JWTDecode( token )
```

### Arguments

| Argument | Type     | Required | Description                         | Default |
| -------- | -------- | -------- | ----------------------------------- | ------- |
| `token`  | `string` | Yes      | Compact JWS token string to decode. |         |

### Returns

A `struct` with two keys:

* `header` — the JOSE header struct (e.g. `{ alg: "RS256", kid: "v2", typ: "JWT" }`)
* `payload` — the claims struct

## Examples

```javascript
decoded = jwtDecode( token );
kid     = decoded.header.kid;     // e.g. "v2"
alg     = decoded.header.alg;     // e.g. "RS256"
sub     = decoded.payload.sub;    // claims are readable without verification

// Typical kid-dispatch pattern
decoded = jwtDecode( token );
key     = getKeyById( decoded.header.kid );
payload = jwtVerify( token, key, decoded.header.alg );
```

## Related

* [JWTVerify()](/boxlang-framework/modularity/jwt/reference/built-in-functions/jwtverify.md) — verify the token before trusting it
* [Key Rotation Guide](/boxlang-framework/modularity/jwt/key-rotation.md) — kid-based dispatch patterns


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/modularity/jwt/reference/built-in-functions/jwtdecode.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
