Base64 to CSS Converter
Decode Base64-encoded CSS stylesheets instantly. Paste Base64 strings or data URIs and get formatted, syntax-highlighted CSS output ready to use.
About
Base64 encoding inflates CSS file size by approximately 33% compared to raw text. Embedded stylesheets using data:text/css;base64,... URIs bypass additional HTTP requests but obscure the underlying rules from inspection and debugging. Misidentifying a corrupted Base64 payload - a single missing pad character (=) or an illegal byte - produces silent rendering failures where styles simply vanish without browser console errors. This tool decodes Base64 strings back to readable CSS, validates the input encoding, and applies syntax formatting so you can audit every selector, property, and value before deployment.
The converter handles both raw Base64 strings and full data URI schemes. It strips the data:[mediatype];base64, prefix automatically before decoding. Note: this tool assumes UTF-8 encoded CSS input. Multi-byte characters outside the ASCII range that were incorrectly encoded at source will produce garbled output - always verify the original encoding chain. Pro tip: if you are extracting Base64 CSS from a bundled JavaScript file, ensure you capture the complete string including trailing = padding characters.
Formulas
Base64 encodes binary data by mapping every 3 bytes (24 bits) to 4 ASCII characters from a 64-character alphabet. The encoded output size is calculated as:
where Soriginal = size of the raw CSS in bytes, and Sencoded = resulting Base64 string length in characters. The overhead ratio converges to exactly 43 ≈ 1.333, yielding the fixed 33.3% inflation.
The decoding process reverses this mapping. Each Base64 character is converted to its 6-bit index value. Four characters produce 24 bits, which split into 3 original bytes:
where idxn = the 6-bit integer value of the n-th Base64 character. Padding characters (=) signal that the final group contains fewer than 3 bytes: one = means 2 bytes remain, two = means 1 byte remains.
Reference Data
| Data URI Prefix | Media Type | Use Case | Size Overhead |
|---|---|---|---|
| data:text/css;base64, | CSS Stylesheet | Inline <link> or @import | 33% |
| data:text/html;base64, | HTML Document | Iframe sources | 33% |
| data:application/json;base64, | JSON | Config embedding | 33% |
| data:image/png;base64, | PNG Image | CSS background-image | 33% |
| data:image/svg+xml;base64, | SVG Vector | Icons, logos | 33% |
| data:font/woff2;base64, | WOFF2 Font | @font-face embedding | 33% |
| data:application/javascript;base64, | JavaScript | Script embedding | 33% |
| data:text/plain;base64, | Plain Text | Generic text data | 33% |
| data:image/jpeg;base64, | JPEG Image | Photo embedding | 33% |
| data:image/webp;base64, | WebP Image | Modern image format | 33% |
| Base64 Character Set (RFC 4648) | |||
| Index Range | Characters | Count | Purpose |
| 0 - 25 | A - Z | 26 | Uppercase alphabet |
| 26 - 51 | a - z | 26 | Lowercase alphabet |
| 52 - 61 | 0-9 | 10 | Digits |
| 62 | + | 1 | 62nd value |
| 63 | / | 1 | 63rd value |
| - | = | 0 - 2 | Padding (mod 3 alignment) |
| Encoding Size Examples | |||
| Original CSS Size | Base64 Encoded Size | Overhead | Padding Chars |
| 1 KB | 1.37 KB | 370 B | 0 - 2 |
| 5 KB | 6.83 KB | 1.83 KB | 0 - 2 |
| 10 KB | 13.65 KB | 3.65 KB | 0 - 2 |
| 50 KB | 68.27 KB | 18.27 KB | 0 - 2 |
| 100 KB | 136.53 KB | 36.53 KB | 0 - 2 |