CSS to Base64
Paste a CSS stylesheet and get the Base64-encoded string in one click.
Last updated: May 29, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is CSS to Base64?
CSS to Base64 encodes a CSS stylesheet as a Base64 string. This is useful when you need to embed a stylesheet in a data URI (e.g., for a self-contained HTML file), pass CSS through an API that only accepts Base64 payloads, or store a stylesheet in a Base64-encoded configuration value.
How to Use CSS to Base64
Paste your CSS into the input.
Click "Encode to Base64".
Toggle URL-safe if needed.
Copy the output.
Common Use Cases
- Embedding a stylesheet in a data URI for use with an iframe srcdoc or object src.
- Passing CSS through a Base64-only API or webhook payload.
- Storing a stylesheet as a Base64 value in a JSON configuration file.
Example Input and Output
Encoding a simple CSS rule to Base64.
body { font-family: sans-serif; }Ym9keSB7IGZvbnQtZmFtaWx5OiBzYW5zLXNlcmlmOyB9Privacy
All encoding runs in your browser. No data is sent to any server.
Frequently Asked Questions
How do I embed the result as a CSS data URI?
Use it as: <link rel="stylesheet" href="data:text/css;base64,<your-base64>">. Note that data URI stylesheets are blocked in some browsers for security reasons.
What is URL-safe Base64?
It replaces + with - and / with _, and removes = padding. Use it when the result will appear in a URL or filename.
Related Tools
Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 to plain text — with URL-safe mode, auto-detect, and size stats.
Base64 to CSS
Decode a Base64 string to CSS. Paste a Base64-encoded image to get a CSS background-image rule, or decode Base64 CSS text back to a stylesheet.
Base64 to Text
Decode Base64 strings back to plain text. Handles UTF-8, URL-safe Base64, and broken padding.
Text to Base64
Encode plain text to Base64 instantly. Handles UTF-8, emojis, and international characters.
HTML to Base64
Encode an HTML document or fragment to Base64 for embedding in JSON payloads, data URIs, or API requests.
APNG to Base64
Convert an Animated PNG (APNG) file to a Base64 string or data URI — paste directly into HTML or CSS without hosting the image.

