All Tools View Categories About Contact Privacy

Policy Document Base64 Encoder/Decoder

Encode an IAM policy document (or any text) to Base64, or decode Base64 back to text.

Runs entirely in your browser using native btoa/atob — nothing is uploaded.

      

      

About Policy Document Base64 Encoder/Decoder

Some AWS workflows and adjacent tooling expect a policy document (or any text) as a Base64 string rather than raw text — embedding it inside another payload, passing it through a system that only accepts opaque blobs, or matching a particular API's expected input encoding. Policy Document Base64 Encoder/Decoder converts pasted text to Base64 and back, using the browser's native btoa/atob functions so the conversion matches exactly what a browser-based script doing the same thing would produce.

Encoding accepts any text, not just policy JSON — paste a policy document, a fragment, or anything else you need encoded. Decoding validates the input before attempting to decode it: text containing characters outside the standard Base64 alphabet, or text with an invalid length/padding, is rejected with a specific error message rather than letting a raw browser exception through.

One honest caveat: btoa/atob only handle Latin1/ASCII text correctly. IAM policy JSON is virtually always plain ASCII, so this rarely matters in practice, but if your text contains non-Latin1 Unicode characters, native btoa can throw or misbehave — a limitation of the browser API this tool intentionally keeps simple rather than working around.

Features

  • Encode any text (including policy JSON) to Base64.
  • Decode Base64 back to text, with input validation.
  • Clear error messages on invalid Base64 input instead of a raw exception.
  • One-click copy of either result.
  • Sample policy JSON to try encoding instantly.
  • 100% client-side — nothing is uploaded.

How to Use

  1. To encode: paste text (or click the sample) in the Encode box and click Encode.
  2. To decode: paste Base64 text in the Decode box and click Decode.
  3. Copy the result with the copy button next to each output.

Examples

Example 1 — encode. {"Version":"2012-10-17","Statement":[]} encodes to eyJWZXJzaW9uIjoiMjAxMi0xMC0xNyIsIlN0YXRlbWVudCI6W119.

Example 2 — decode. Pasting that same Base64 string into the decoder returns the original JSON exactly.

Example 3 — invalid input. Pasting plain text with spaces and punctuation into the decoder (not valid Base64) returns a clear "does not look like valid Base64" error instead of garbage output.

Benefits

  • Encode or decode in one place, no separate CLI or online tool needed.
  • Validates before decoding, so bad input fails clearly instead of silently.
  • Uses the browser's native, standards-based Base64 implementation.
  • Private — encoding/decoding runs entirely in your browser.

Frequently Asked Questions

Why would I need to Base64-encode a policy document?
Several AWS APIs and CLI flows expect certain inputs Base64-encoded — for example some Lambda environment variable patterns, embedding a document inside another JSON/XML payload, or storing it in a system that only accepts opaque text blobs. This tool encodes and decodes any text, including policy JSON, without judging what you use it for.
Does this handle non-ASCII characters correctly?
It uses the browser's native <code>btoa</code>/<code>atob</code> functions, which only handle Latin1/ASCII text correctly by design. IAM policy JSON is virtually always plain ASCII (action names, ARNs, and standard JSON punctuation), so this is rarely an issue in practice — but if your text contains non-Latin1 Unicode characters (e.g. non-English text inside a <code>Sid</code> or a Condition value), a plain <code>btoa</code> call can throw or produce incorrect output. The standard workaround (not implemented here) is the <code>encodeURIComponent</code> + <code>unescape</code> trick or the <code>TextEncoder</code> API.
What happens if I paste invalid Base64 into the decoder?
You get a clear error message — either that the text contains characters outside the Base64 alphabet, or that the decoder rejected the input as malformed — instead of a raw, confusing browser exception.
Does encoding or decoding change my policy JSON in any way?
No. Base64 is a reversible text-to-text encoding; the exact original bytes come back out on decode. Nothing about the policy's structure, keys, or values is altered.
Is my text uploaded anywhere?
No — encoding and decoding both run entirely in your browser using native <code>btoa</code>/<code>atob</code>.