All Tools

Text to Data URI Converter, Free and Private

Turn text into a data: URI with Base64 or percent-encoding and your chosen MIME type, or read the text back out of a data URI, in your browser. Nothing is uploaded.

Mode

0 characters, 0 bytes

0 characters, 0 bytes


About the text to data URI converter

This page turns text into a data: URI and reads the text back out of one, in your browser. A data URI carries its content inside the address itself, so a small piece of HTML, CSS, SVG, JSON or plain text can be opened, linked or embedded without a separate file. Type your text and the URI appears at once, for example data:text/plain;charset=utf-8;base64,SGk= for Hi. Nothing is uploaded: the conversion runs on your device and your text never leaves it.

How to make a data URI from text

Text to data URI

  1. Keep Mode on Text to data URI and type or paste your text.
  2. Set the MIME type. text/plain is the default; use text/html for a page, text/css for a stylesheet, image/svg+xml for an SVG drawing or application/json for data.
  3. Leave the data as Base64, or turn on Percent-encode instead of Base64 for a URI you can still read by eye.
  4. Press Copy and paste the URI into a link, an iframe, a CSS url() or your browser's address bar.

Data URI to text

  1. Choose Data URI to text and paste a URI that starts with data:.
  2. Base64 and percent-encoded URIs are both accepted, and the charset parameter is honoured.
  3. If the URI holds an image, a font or another binary type, the page says so and offers the bytes as a download instead of showing unreadable characters.

Privacy

The encoding and decoding happen entirely in your browser. Your text is never sent to our servers, and nothing is kept once you close the tab.

How a data URI is built

A data URI has four parts: the word data:, a media type such as text/plain, optional parameters such as charset=utf-8, and after a comma the data itself. When the parameters end in ;base64, the data is Base64; otherwise it is percent-encoded, which means every byte outside the safe set is written as % and two hexadecimal digits. This page always writes charset=utf-8, because the text is turned into bytes with UTF-8, so accented letters and emoji survive the round trip.

Base64 or percent-encoding?

Base64 grows the text by about a third but always produces a compact run of letters, digits, +, / and =. Percent-encoding leaves plain letters and digits alone, so mostly ASCII text such as SVG or CSS stays short and readable, while text full of accents or non-Latin scripts grows to three characters per byte. Pick whichever is shorter for your text.

The ASCII check

Turn on ASCII only when the receiving system accepts only 7-bit ASCII. The first character above U+007F is then reported with its code point and position, so you can replace a curly quote, a non-breaking space or an accented letter before you embed the URI, instead of finding out later.

Things to know

  • Browsers limit data URIs in places. Many browsers refuse to open a data:text/html URI typed into the address bar from a link on another site, as an anti-phishing measure. Embedding in an iframe or img still works.
  • A data URI without a media type is plain text. The standard says data:,hello means text/plain;charset=US-ASCII; this page reads such URIs as UTF-8, which gives the same result for ASCII text.
  • Large data URIs are slow. Every use repeats the whole content, so for anything bigger than a few kilobytes a separate file is usually better.

Open-source credits

The data URI logic is implemented in-house. It follows RFC 2397 (The "data" URL scheme) for the URI layout and its defaults, RFC 4648 for the Base64 alphabet, and RFC 3986 for percent-encoding. Text is converted with the browser's built-in TextEncoder and TextDecoder from the WHATWG Encoding Standard. No third-party library is involved.

Related tools

The full Base64 encoder and decoder also encodes files and offers URL-safe Base64. For percent-encoding text that goes into a query string rather than a data URI, use the URL encoder and decoder, and to escape characters for HTML instead, use the HTML entity encoder.

Other related tools