{
    "slug": "jwt-encoder-and-decoder",
    "name": "JWT Encoder and Decoder",
    "url": "https://directory.milunir.com/developer-tools/encoders-decoders/jwt-encoder-and-decoder/",
    "description": "Decode a JSON Web Token into its header and claims, check an HS256 signature against a secret, or sign a JSON payload. Runs in your browser.",
    "inputs": {
        "type": "object",
        "properties": {
            "mode": {
                "type": "string",
                "enum": [
                    "decode",
                    "verify",
                    "sign"
                ],
                "description": "Mode",
                "default": "decode"
            },
            "token": {
                "type": "string",
                "description": "JWT. The three dot-separated parts. A leading \"Bearer \" is ignored."
            },
            "payload": {
                "type": "string",
                "description": "Payload (JSON). The claims to put in the token, as one JSON object.",
                "default": "{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"iat\":1516239022}"
            },
            "secret": {
                "type": "string",
                "description": "Secret. The shared HS256 key. It stays in this page and is never sent anywhere."
            },
            "secret_b64": {
                "type": "boolean",
                "description": "Secret is base64url-encoded. Tick this when the key is stored as base64url bytes, as in a JWK \"k\" value.",
                "default": false
            }
        },
        "additionalProperties": false
    },
    "outputs": [
        {
            "key": "primary",
            "label": "Result"
        },
        {
            "key": "algorithm",
            "label": "Algorithm"
        },
        {
            "key": "detail",
            "label": "Details"
        },
        {
            "key": "signature",
            "label": "Signature"
        }
    ],
    "modes": [
        {
            "id": "decode",
            "label": "Decode",
            "inputs": [
                "token"
            ]
        },
        {
            "id": "verify",
            "label": "Verify",
            "inputs": [
                "token",
                "secret",
                "secret_b64"
            ]
        },
        {
            "id": "sign",
            "label": "Sign",
            "inputs": [
                "payload",
                "secret",
                "secret_b64"
            ]
        }
    ],
    "feed": null,
    "endpoint": "https://api.tools-directory.workers.dev/v1/tools/jwt-encoder-and-decoder",
    "mcp_tool": "jwt_encoder_and_decoder",
    "example": {
        "inputs": {
            "mode": "decode",
            "token": "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
        },
        "output": "Result: {\n  \"iss\": \"joe\",\n  \"exp\": 1300819380,\n  \"http://example.com/is_root\": true\n}\nDetails: Signature not checked"
    }
}