Base64 Files
Format Check · Error Location · Instant Feedback

Base64 Validator

Paste a Base64 string or Data URL to instantly check if it is valid. Shows type, MIME, length, estimated original size, padding status, and precise invalid character position.

Validation Result

Waiting for input…

Type
MIME Type
Base64 Length
Estimated Size
Padding (=)

What Is Valid Base64?

A valid Base64 string must contain only A–Z, a–z, 0–9, +, / (64 characters total), plus at most 2 trailing padding characters =, and the total length must be a multiple of 4.

Data URL adds a data:<MIME>;base64, prefix before the Base64 data, commonly found in HTML img src or CSS background-image.

Base64URL replaces + with - and / with _, removing trailing = padding, for use in JWT, URL parameters, and other URL-safe contexts.

Valid Character Reference

Raw Base64A–Z a–z 0–9 + / = (trailing)
Base64URLA–Z a–z 0–9 - _ (no padding)
Data URLdata:<MIME>;base64,<Base64 data>
Invalid Charactersspace newline ä CJK ! @ # % …

Common Error Causes

  • Contains Invalid Characters

    Spaces, newlines, CJK characters, ! @ # and others are not part of the Base64 character set and are often accidentally included when copying.

  • Length Not a Multiple of 4

    Missing trailing padding characters =, often caused by manually truncating or partially copying a Base64 string.

  • Padding in Wrong Position

    The = padding character can only appear at the end, with at most 2 characters. A string with = in the middle is invalid.

  • Mixing Base64 and Base64URL

    Using Raw Base64 (with + and /) in a URL parameter, or passing Base64URL (with - and _) to a standard decode function, will cause decoding failures.

  • Missing Data URL Prefix

    When setting an img src, copying only the Base64 data without the data:image/png;base64, prefix will cause the image to fail to load.

  • Line Break Interference

    Some tools insert a line break every 76 characters for MIME email transport (RFC 2045). These must be removed before using in an API or URL.

Frequently Asked Questions

What makes a Base64 string valid?

A valid Base64 string can only contain A–Z, a–z, 0–9, +, /, and at most 2 trailing padding characters =, with a total length that is a multiple of 4. If it has a data: prefix, it must also follow the Data URL format.

Why does "Base64 decode failed" appear?

The most common reasons are: the string contains invalid characters (such as spaces, newlines, or CJK characters), the length is not a multiple of 4 (missing padding), or the = padding is not at the end. Paste the string into this tool to pinpoint the problem.

What is the difference between Base64 and Base64URL?

Base64URL replaces + with - and / with _ in standard Base64, and usually omits the trailing = padding, making it safe for URL parameters and JWT tokens. If your string contains - or _, it is Base64URL format.

What is the Data URL format?

A Data URL has the format data:<MIME type>;base64,<Base64 data>, for example data:image/png;base64,iVBORw0…. The MIME type specifies the format of the original data.

How is the estimated original size calculated?

Original bytes = ⌊Base64 length × 3 / 4⌋ − padding count. Since Base64 maps every 4 characters to 3 bytes, the tool can accurately restore the original size (assuming correct padding).

Does a valid Base64 string always decode correctly?

A valid format is a prerequisite for decoding, but does not guarantee the decoded content is meaningful. For example, a random string may pass the format check, but the decoded binary data may not be parseable as a file or text.