Data URI to ASCII Converter

Parses an RFC 2397 data URI restricted to the text/plain, base64-encoded form, decodes the payload, and strictly validates that the decoded text is 7-bit ASCII, rejecting other MIME types, non-base64 data URIs, and any decoded byte above 127. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

Data URIs are everywhere in HTML, CSS, and JavaScript source, but reading the actual text behind one usually means manually stripping the scheme prefix and decoding the Base64 by hand.

This tool does that parsing for you, specifically for the text/plain, base64-encoded form, then adds a strict ASCII check on the result so you know exactly what kind of text you got back.

What Is Data URI to ASCII Converter?

A parser and decoder for RFC 2397 data URIs restricted to the data:text/plain;...;base64,<data> form, the counterpart to ASCII to Data URI Converter.

It doesn't attempt to handle every data URI variant (images, other MIME types, percent-encoded payloads); it's purpose-built for the ASCII text/plain case.

How Data URI to ASCII Converter Works

The trimmed input is matched against a pattern requiring the data:text/plain scheme, an optional charset parameter, and the ;base64, marker; anything else is rejected with a specific error before decoding.

The base64 payload is decoded via atob(), then the decoded text is validated character-by-character against the 0-127 ASCII range using this category's shared strict-ASCII validator.

When To Use Data URI to ASCII Converter

Use it to read the actual text content behind a data:text/plain;base64,... URI found in HTML, CSS, or JavaScript source, or to confirm it's genuinely ASCII.

If you already have the bare Base64 string without the data: prefix, use Base64 to ASCII Converter directly instead.

Features

Advantages

  • Parses the data URI scheme so you don't have to manually strip the prefix before decoding.
  • Rejects non-text/plain or non-base64 data URIs outright, rather than trying to guess what to do with them.
  • Applies the same strict ASCII guarantee as every other tool in this category to the decoded result.

Limitations

  • Only supports the base64-encoded text/plain form; percent-encoded data URIs and other MIME types are rejected.
  • Rejects a decoded result containing any byte above 127, even if the data URI itself was syntactically well-formed.

Examples

Decoding a data URI with an explicit charset

Input

data:text/plain;charset=us-ascii;base64,SGVsbG8=

Output

Hello

The scheme, MIME type, charset, and base64 marker are all recognized and stripped before the payload is decoded.

Decoding a data URI without a charset parameter

Input

data:text/plain;base64,SGkh

Output

Hi!

The charset parameter is optional; the pattern still matches and decodes correctly without it.

Rejecting a non-text/plain data URI

Input

data:application/json;base64,e30=

Output

Input is not a "data:text/plain;base64,..." URI. Only the base64-encoded text/plain form is supported.

The MIME type is application/json, not text/plain, so the URI is rejected before any decoding is attempted.

Best Practices & Notes

Best Practices

  • If you're not sure a data URI is the base64 form, paste it here first; a clear rejection tells you immediately if it's a different MIME type or encoding.
  • Pair with ASCII to Data URI Converter to confirm a round trip produces the exact same URI you started with.

Developer Notes

The scheme is matched with /^data:text\/plain(;charset=[\w-]+)?;base64,([\s\S]*)$/i, the captured payload is decoded via atob() inside a try/catch for malformed Base64, and the decoded string is then run through the category's shared validateStrictAscii helper.

Data URI to ASCII Converter Use Cases

  • Reading the plain-text content embedded in a data URI found in HTML, CSS, or JavaScript source
  • Verifying that a data URI genuinely declares and contains us-ascii text before trusting it downstream
  • Debugging a data URI that isn't decoding the way a script expects

Common Mistakes

  • Pasting a data URI for an image or other binary MIME type and expecting readable text back, this tool only handles text/plain.
  • Assuming a decode failure means the data URI is malformed, when it might just contain non-ASCII text, which the URI syntax itself allows but this tool's stricter check rejects.

Tips

  • A rejection naming a decoded byte above 127 usually means the original text wasn't pure ASCII, not that the data URI itself is broken.
  • Re-encode the decoded text with ASCII to Data URI Converter to confirm you land back on an equivalent URI.

References

Frequently Asked Questions