# Base64 Codec

**MCP Tool:** `base64_codec`  
**Tier:** Tier 1 — Commodity  
**Category:** encoders  
**Endpoint:** https://obfus.link/mcp  
**Price:** $0.008 / call  
**Verification:** ✓ TDD verified  

> Encode, decode, and identify base64 with auto-detection

## Atomic Answer

Base64 Codec encodes and decodes standard, URL-safe, and MIME base64 variants. Identify mode auto-detects the variant and reveals the content type of any opaque base64 payload — JSON, JWT, image, PEM certificate, protobuf, or plain text — and parses JWT header and payload structures into typed objects ready for inspection.

## Description

Encodes and decodes standard, URL-safe, and MIME base64 variants. Identify mode auto-detects the variant and reveals the content type of any opaque base64 payload — JSON, JWT, image, PEM certificate, protobuf, or plain text — and parses JWT header and payload structures.

## Agentic Reasoning

USE THIS WHEN: (1) You receive an opaque base64 payload from an API and need to know what it contains before deciding how to process it — Identify mode reveals JSON, JWT, image, PEM certificate, protobuf, or plain text. (2) You need to decode URL-safe base64 (e.g., from a JWT header or payload segment) and standard base64 decoders fail. (3) You are encoding binary data for a context that requires a specific variant (URL-safe for query params, MIME for email). DO NOT USE WHEN: you know the content type and just need raw encoding — use btoa/atob for standard base64 in browsers, or Buffer.from in Node. OVER ALTERNATIVES: prefer over btoa/atob (no URL-safe variant, no content identification, no JWT parsing) and online decoders (no MCP API, no auto-detection).

## MCP Description

Encodes, decodes, and identifies base64 strings. USE WHEN: encoding/decoding any base64 variant, or you need to identify what an opaque base64 string contains. INPUT: input string and mode (encode/decode/identify). OUTPUT: encoded or decoded string, detected variant, content type for identify mode, and parsed JWT structure if applicable. COST: 1 unit.

## Input Schema

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `mode` | `encode` \| `decode` \| `identify` | yes |  |
| `input` | `string` | yes |  |
| `variant` | `standard` \| `url-safe` \| `mime` | no |  |
| `inputEncoding` | `utf-8` \| `ascii` \| `binary` | no |  |

## Output Schema

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `output` | `string` | no |  |
| `variant` | `string` | no |  |
| `jwtParts` | `object` | no |  |
| `contentType` | `string` | no |  |
| `contentPreview` | `string` | no |  |

## How To Use

1. **Choose mode** — encode (text → base64), decode (base64 → text), or identify (auto-detect content type).
2. **Select variant** — standard (RFC 4648), url-safe (replaces + and / with - and _), or mime (line-broken).
3. **Paste input** — For encode: text or binary. For decode/identify: any base64 variant.
4. **Run** — Click Run or press Ctrl+Enter. Output shows the result, detected variant, and content type for identify mode.

## FAQs

**What is the difference between standard and URL-safe base64?**

Standard base64 (RFC 4648) uses A-Z, a-z, 0-9, +, /, and = for padding. URL-safe replaces + with - and / with _ so the output can appear in URL query parameters and JWT segments without percent-encoding. Padding is often omitted in URL-safe variants.

**What does Identify mode detect?**

JSON (parses and previews), JWT (parses header and payload into structured objects), images (detects PNG, JPEG, GIF, WebP from magic bytes), PEM certificates (RSA, EC, X.509), protobuf (byte-pattern heuristic), and plain text. The decoded preview shows the first 200 characters.

**What is MIME base64?**

MIME base64 (RFC 2045) is standard base64 with line breaks every 76 characters — the format required for email attachments and PEM certificate payloads. Decoders must strip line breaks before decoding; the codec handles this automatically.

**Can I use this tool via the MCP API?**

Yes. The tool is registered on the obfus.link MCP server at https://obfus.link/mcp. Call it from any MCP-compatible agent with a Shared Payment Token. The MCP tool name matches the snake_case slug shown in the integration snippet.

## Tags

`base64` · `encode` · `decode` · `jwt` · `binary`

---

*obfus.link — A Subether Labs Infrastructure Project*  
*Canonical URL: https://obfus.link/tool/base64-codec*  
*JSON view: https://obfus.link/tool/base64-codec/json*
