Base64 Files
Strip Noise · Fix Format · Instant Output

Base64 Cleaner

Base64 copied from JSON, logs, emails, or code often carries extra quotes, newlines, JSON escapes, or Data URL prefixes. Paste it in — get clean Base64, Data URL, or wrapped format in one click.

Why Does Base64 Get "Dirty"?

From JSON

Double quotes, \n newline escapes, \/ slash escapes

"SGVsbG8s\nIFdvcmxkIQ=="

From HTML / CSS

data:image/png;base64, prefix, quotes

"data:image/png;base64,iVBOR…"

From SMTP Email

Hard line break every 76 chars (RFC 2045)

SGVsbG8sIFdv cmxkIQ==

From Logs / Terminal

Line numbers, timestamps, indentation mixed in

[INFO] payload: SGVsbG8s IFdvcmxk

From Code Comments

// or # prefixes, trailing spaces

// SGVsbG8s // IFdvcmxk

From API Response

Field value with quotes, field name copied along

{\"data\": \"SGVsbG8s…\"}

Cleaning Order

The tool processes in a fixed sequence, ensuring each step doesn't interfere with the next.

  1. 1

    Strip JSON Escapes

    Replace \n \r \t \" \/ \\ with the corresponding character or empty string

  2. 2

    Extract Data URL

    Detect data:<MIME>;base64, prefix, record MIME type, strip the prefix

  3. 3

    Remove Quotes

    Delete all " and ' characters from the string

  4. 4

    Strip Whitespace

    Remove all spaces, tabs, and newlines (\n \r \t)

  5. 5

    Fix Padding

    If length is not a multiple of 4, append = or == to the end

Output Format Guide

Clean Base64

Pure Base64 string, single line, no prefix or newlines. Ready to pass directly to a decode function or API.

SGVsbG8sIFdvcmxkIQ==

Data URL

Prepends data:<MIME>;base64, prefix — use directly in HTML img src or CSS background-image.

data:image/png;base64,SGVs…

Multiline

Wrapped at 76 chars per line, per RFC 2045 / PEM spec. For MIME email attachments or certificate files.

SGVsbG8sIFdv cmxkIQ==

Frequently Asked Questions

Why can't I use Base64 copied from JSON directly?

JSON string values include double quotes, and newlines are escaped as \n. Sometimes / is also escaped as \/. Pasting these into a Base64 decoder causes invalid character errors. This tool automatically detects and cleans those JSON escapes.

What is a Data URL prefix and why remove it?

A Data URL has the format data:<MIME>;base64,<data>. The prefix is not Base64 data — feeding it to a decoder causes errors from characters like data:, :, etc. This tool extracts the MIME type from the prefix and outputs the raw Base64 separately.

What is RFC 2045 multiline format?

RFC 2045 is the MIME email spec requiring Base64 lines no longer than 76 characters separated by newlines. SMTP and some crypto/signing libraries (e.g. PEM certificate format) follow this convention. Multiline format doesn't affect the Base64 data — it just adds line breaks.

Does adding padding change the original data?

No. The padding character = is part of the Base64 encoding format, making the string length a multiple of 4. Base64 with or without padding decodes to exactly the same result. Some libraries (like Base64URL) intentionally omit padding, but standard decoders usually require it.

Can I use the cleaned Base64 directly in <img src>?

Select the "Data URL" tab, choose the correct MIME type (e.g. image/png), and copy the output. The Data URL format works directly as an HTML img src attribute or CSS background-image.

If the cleaned result still won't decode, what's wrong?

The original data may be corrupted (not a complete Base64 string), or it may contain Base64URL characters - and _ (as opposed to + and / in standard Base64). Paste the cleaned result into the Base64 Validator for further diagnosis.