> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
