Image to Base64

Encode image files to Base64 string via drag & drop or file picker.

๐Ÿ“ค

Drag & drop an image here or click to select

๐Ÿ“– How to Use

1
Upload Image

Drag & drop or click to select an image file (JPG, PNG, GIF, SVG, etc.).

2
Auto Encode

The image is instantly converted to a Base64 string upon selection.

3
Copy or Download

Use ๐Ÿ“‹ Copy to save the Base64 string to clipboard, or ๐Ÿ’พ Download to save as a text file.

๐Ÿ’ก Tip: Base64-encoded images can be used directly in CSS background-image or HTML img src. Note that file size increases by about 33%.

About the Image to Base64 Encoder

Normally a browser fetches each image with its own HTTP request, trading a small latency cost for caching the file independently. Sometimes you would rather embed the bytes directly — a favicon in an HTML email, a tiny logo in a single-file widget, or a UI icon inside a component. Base64 encoding makes that possible: it rewrites binary image data as a plain ASCII string the browser decodes inline. This tool reads a dropped file and produces that string, ready to paste into an <img src> or a CSS url().

How it works

The output uses the data URI scheme: data:<mime>;base64,<bytes>. For a PNG the prefix is data:image/png;base64, followed by the Base64 bytes; a JPEG uses data:image/jpeg;base64,, and SVG can be inlined as data:image/svg+xml, without the base64 flag. Base64 maps every three bytes of input onto four printable characters from a 64-symbol alphabet (A–Z, a–z, 0–9, +, /), padded with =. That is what lets arbitrary binary travel safely inside a text format.

The trade-off is size. Because four characters carry only three bytes, the string is roughly 33% larger than the original. Inlining also defeats separate caching — the bytes live inside the HTML and re-fetched every time the document is — and bloats the page, which can delay first paint for large images. A strict Content Security Policy must also explicitly allow data: in img-src for these URIs to load.

Common use cases

  • Embedding a favicon or logo in a single HTML file or email
  • Inlining small UI icons inside a CSS bundle to cut HTTP requests
  • Shipping a self-contained SVG/PNG demo with no asset folder
  • Passing an image as a string inside JSON for a config payload

Worked example

A 1 KB PNG dropped in produces a data URI that begins:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...

Paste that straight into markup:

<img src="data:image/png;base64,iVBORw0KGgo..."
     alt="logo" width="32" height="32">

Or into CSS as a background:

.logo { background: url("data:image/png;base64,iVBORw0KGgo..."); }

Note the ~33% overhead — the 1 KB PNG becomes about 1.3 KB in HTML.

Frequently asked questions

What is a data URI?

A data URI is a URL whose payload is embedded inline rather than fetched. It begins with the scheme data:, followed by a MIME type such as image/png, an optional ;base64 flag, and the encoded bytes. A browser can render data:image/png;base64,.... directly as an image with no separate HTTP request.

How much larger is a Base64-encoded image?

Base64 encodes every 3 bytes of binary into 4 ASCII characters, so the encoded string is about 33% larger than the original file. For small icons and sprites this overhead is negligible; for large photos or video it is wasteful and a separate file is usually better.

When should I inline an image as Base64?

Inlining helps for small, rarely-changing assets (favicons, UI icons, tiny logos) where avoiding an extra HTTP request outweighs the size cost. It hurts for large images, since the inlined bytes bloat HTML, cannot be cached independently, and block parsing of the document.

Are my images uploaded anywhere?

No. The file is read with the browser FileReader API and encoded locally. The bytes never leave your device, so the tool is safe for confidential or unreleased artwork.

Does Base64 affect Content Security Policy?

It can. A strict img-src directive must allow data: URIs (img-src 'self' data:) for inlined images to load. Check your CSP headers before relying on data URIs in production.

์ด๋ฏธ์ง€ Base64 ์ธ์ฝ”๋”๋ž€?

๋ณดํ†ต ๋ธŒ๋ผ์šฐ์ €๋Š” ๊ฐ ์ด๋ฏธ์ง€๋ฅผ ๋ณ„๋„์˜ HTTP ์š”์ฒญ์œผ๋กœ ๊ฐ€์ ธ์˜ค๋ฉฐ, ํŒŒ์ผ์„ ๋…๋ฆฝ์ ์œผ๋กœ ์บ์‹œํ•  ์ˆ˜ ์žˆ๋Š” ์ด์ ๊ณผ ์ž‘์€ ์ง€์—ฐ์„ ๋งž๋ฐ”๊ฟ‰๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฐ”์ดํŠธ๋ฅผ ๋ฌธ์„œ์— ์ง์ ‘ ํฌํ•จ์‹œํ‚ค๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค — HTML ์ด๋ฉ”์ผ์˜ ํŒŒ๋น„์ฝ˜, ๋‹จ์ผ ํŒŒ์ผ ์œ„์ ฏ ์•ˆ์˜ ์ž‘์€ ๋กœ๊ณ , ๋˜๋Š” ๋ณ„๋„ ์—์…‹ ์—†์ด ์ปดํฌ๋„ŒํŠธ์— ๋‹ด์•„ ๋ฐฐํฌํ•˜๋Š” UI ์•„์ด์ฝ˜์ฒ˜๋Ÿผ์š”. Base64 ์ธ์ฝ”๋”ฉ์ด ์ด๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์ด์ง„ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ธ๋ผ์ธ์œผ๋กœ ๋””์ฝ”๋”ฉํ•  ์ˆ˜ ์žˆ๋Š” ์ผ๋ฐ˜ ASCII ๋ฌธ์ž์—ด๋กœ ๋‹ค์‹œ ์“ฐ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ๋„๊ตฌ๋Š” ๋“œ๋กญํ•œ ํŒŒ์ผ์„ ์ฝ๊ณ  ๊ทธ ๋ฌธ์ž์—ด์„ ๋งŒ๋“ค์–ด <img src>๋‚˜ CSS url()์— ๋ฐ”๋กœ ๋ถ™์—ฌ๋„ฃ์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

์ž‘๋™ ๋ฐฉ์‹

๊ฒฐ๊ณผ๋ฌผ์€ data URI ์Šคํ‚ด์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค: data:<mime>;base64,<bytes>. PNG์˜ ์ ‘๋‘์‚ฌ๋Š” data:image/png;base64, ๋’ค์— Base64๋กœ ์ธ์ฝ”๋”ฉ๋œ ์ด๋ฏธ์ง€๊ฐ€ ์˜ค๊ณ , JPEG๋Š” data:image/jpeg;base64,๋ฅผ ์”๋‹ˆ๋‹ค. SVG๋Š” base64 ํ”Œ๋ž˜๊ทธ ์—†์ด data:image/svg+xml,๋กœ ์ธ๋ผ์ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. Base64 ์ž์ฒด๋Š” ์ž…๋ ฅ์˜ 3๋ฐ”์ดํŠธ๋งˆ๋‹ค 64๊ฐœ ๊ธฐํ˜ธ ์•ŒํŒŒ๋ฒณ(A–Z, a–z, 0–9, +, /)์˜ ์ถœ๋ ฅ ๊ฐ€๋Šฅ ๋ฌธ์ž 4๊ฐœ๋กœ ๋งคํ•‘ํ•˜๋ฉฐ, ๋์€ =์œผ๋กœ ํŒจ๋”ฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋•๋ถ„์— ์ž„์˜์˜ ์ด์ง„ ๋ฐ์ดํ„ฐ๊ฐ€ HTML, CSS, JSON ๊ฐ™์€ ํ…์ŠคํŠธ ํ˜•์‹ ์•ˆ์—์„œ ์•ˆ์ „ํ•˜๊ฒŒ ์ด๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŠธ๋ ˆ์ด๋“œ์˜คํ”„๋Š” ํฌ๊ธฐ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž 4๊ฐœ๊ฐ€ 3๋ฐ”์ดํŠธ๋งŒ ๋‹ด์œผ๋ฏ€๋กœ ์ธ์ฝ”๋”ฉ๋œ ๋ฌธ์ž์—ด์€ ์›๋ณธ๋ณด๋‹ค ๋Œ€๋žต 33% ๋” ํฝ๋‹ˆ๋‹ค. ์ธ๋ผ์ธ์€ ๋˜ํ•œ ๊ฐœ๋ณ„ ์บ์‹ฑ์„ ๋ฌด๋ ฅํ™”ํ•ฉ๋‹ˆ๋‹ค — ๋ฐ”์ดํŠธ๊ฐ€ HTML ์•ˆ์— ์‚ด๊ณ  ๋ฌธ์„œ๋ฅผ ๊ฐ€์ ธ์˜ฌ ๋•Œ๋งˆ๋‹ค ํ•จ๊ป˜ ๋‹ค์‹œ ์ „์†ก๋ฉ๋‹ˆ๋‹ค — ๊ทธ๋ฆฌ๊ณ  ํŽ˜์ด์ง€๋ฅผ ๋ถ€ํ’€๋ ค ํฐ ์ด๋ฏธ์ง€์— ์“ฐ๋ฉด ์ฒซ ํŽ˜์ธํŠธ๋ฅผ ์ง€์—ฐ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ ์—„๊ฒฉํ•œ Content Security Policy๋Š” ์ด URI๊ฐ€ ๋กœ๋“œ๋˜๋ ค๋ฉด img-src์— data:๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ํ—ˆ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ž์ฃผ ์“ฐ๋Š” ๊ฒฝ์šฐ

  • ๋‹จ์ผ HTML ํŒŒ์ผ์ด๋‚˜ ์ด๋ฉ”์ผ์— ํŒŒ๋น„์ฝ˜ยท๋กœ๊ณ  embedํ•˜๊ธฐ
  • CSS ๋ฒˆ๋“ค ์•ˆ์— ์ž‘์€ UI ์•„์ด์ฝ˜์„ ์ธ๋ผ์ธํ•ด HTTP ์š”์ฒญ ์ค„์ด๊ธฐ
  • ์—์…‹ ํด๋” ์—†์ด ์ž์ฒด ํฌํ•จ๋œ SVG/PNG ๋ฐ๋ชจ ๋ฐฐํฌํ•˜๊ธฐ
  • ์ด๋ฏธ์ง€๋ฅผ JSON ์•ˆ์˜ ๋ฌธ์ž์—ด๋กœ config ํŽ˜์ด๋กœ๋“œ์— ๋‹ด๊ธฐ

์‚ฌ์šฉ ์˜ˆ

1ํ‚ฌ๋กœ๋ฐ”์ดํŠธ์งœ๋ฆฌ PNG๋ฅผ ๋“œ๋กญํ•˜๋ฉด ๋‹ค์Œ์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” data URI๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...

์ด๋ฅผ ๋งˆํฌ์—…์— ๋ฐ”๋กœ ๋ถ™์—ฌ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

<img src="data:image/png;base64,iVBORw0KGgo..."
     alt="logo" width="32" height="32">

๋˜๋Š” CSS ๋ฐฐ๊ฒฝ์œผ๋กœ:

.logo { background: url("data:image/png;base64,iVBORw0KGgo..."); }

์•ฝ 33%์˜ ํฌ๊ธฐ ์˜ค๋ฒ„ํ—ค๋“œ์— ์œ ์˜ํ•˜์„ธ์š” — ๋””์Šคํฌ์—์„œ 1 KB์˜€๋˜ ๊ฐ™์€ PNG๊ฐ€ HTML ์•ˆ์—์„œ๋Š” ์•ฝ 1.3 KB๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

data URI๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

data URI๋Š” ํŽ˜์ด๋กœ๋“œ๋ฅผ ๊ฐ€์ ธ์˜ค์ง€ ์•Š๊ณ  ์ธ๋ผ์ธ์œผ๋กœ embedํ•œ URL์ž…๋‹ˆ๋‹ค. data: ์Šคํ‚ด์œผ๋กœ ์‹œ์ž‘ํ•ด image/png ๊ฐ™์€ MIME ํƒ€์ž…, ์„ ํƒ์  ;base64 ํ”Œ๋ž˜๊ทธ, ์ธ์ฝ”๋”ฉ๋œ ๋ฐ”์ดํŠธ๊ฐ€ ์ด์–ด์ง‘๋‹ˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋Š” ๋ณ„๋„ HTTP ์š”์ฒญ ์—†์ด data:image/png;base64,....๋ฅผ ์ด๋ฏธ์ง€๋กœ ๋ฐ”๋กœ ๋ Œ๋”๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Base64๋กœ ์ธ์ฝ”๋”ฉ๋œ ์ด๋ฏธ์ง€๋Š” ์–ผ๋งˆ๋‚˜ ์ปค์ง€๋‚˜์š”?

Base64๋Š” ์ด์ง„ 3๋ฐ”์ดํŠธ๋งˆ๋‹ค ASCII ๋ฌธ์ž 4๊ฐœ๋กœ ์ธ์ฝ”๋”ฉํ•˜๋ฏ€๋กœ, ์ธ์ฝ”๋”ฉ๋œ ๋ฌธ์ž์—ด์€ ์›๋ณธ๋ณด๋‹ค ์•ฝ 33% ๋” ํฝ๋‹ˆ๋‹ค. ์ž‘์€ ์•„์ด์ฝ˜์ด๋‚˜ ์Šคํ”„๋ผ์ดํŠธ์—๋Š” ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ๋ฏธ๋ฏธํ•˜์ง€๋งŒ, ํฐ ์‚ฌ์ง„์ด๋‚˜ ๋น„๋””์˜ค์—๋Š” ๋‚ญ๋น„์ด๋ฏ€๋กœ ๋ณดํ†ต ๋ณ„๋„ ํŒŒ์ผ์ด ๋‚ซ์Šต๋‹ˆ๋‹ค.

์ด๋ฏธ์ง€๋ฅผ Base64๋กœ ์–ธ์ œ ์ธ๋ผ์ธํ•ด์•ผ ํ•˜๋‚˜์š”?

์ถ”๊ฐ€ HTTP ์š”์ฒญ์„ ํ”ผํ•˜๋Š” ์ด๋“์ด ํฌ๊ธฐ ๋น„์šฉ๋ณด๋‹ค ํฐ, ์ž‘๊ณ  ์ž˜ ์•ˆ ๋ฐ”๋€Œ๋Š” ์—์…‹(ํŒŒ๋น„์ฝ˜, UI ์•„์ด์ฝ˜, ์ž‘์€ ๋กœ๊ณ )์— ์ธ๋ผ์ธ์ด ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ํฐ ์ด๋ฏธ์ง€์—๋Š” ๋ถˆ๋ฆฌํ•ฉ๋‹ˆ๋‹ค — ์ธ๋ผ์ธ๋œ ๋ฐ”์ดํŠธ๊ฐ€ HTML์„ ๋ถ€ํ’€๋ฆฌ๊ณ , ๋…๋ฆฝ์ ์œผ๋กœ ์บ์‹œํ•  ์ˆ˜ ์—†์œผ๋ฉฐ, ๋ฌธ์„œ ํŒŒ์‹ฑ์„ ๋ง‰๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

์ œ ์ด๋ฏธ์ง€๊ฐ€ ์–ด๋””๋กœ ์—…๋กœ๋“œ๋˜๋‚˜์š”?

์•„๋‹™๋‹ˆ๋‹ค. ํŒŒ์ผ์€ ๋ธŒ๋ผ์šฐ์ €์˜ FileReader API๋กœ ์ฝ๊ณ  ๋กœ์ปฌ์—์„œ ์ธ์ฝ”๋”ฉ๋ฉ๋‹ˆ๋‹ค. ๋ฐ”์ดํŠธ๋Š” ๊ธฐ๊ธฐ๋ฅผ ๋– ๋‚˜์ง€ ์•Š์œผ๋ฏ€๋กœ ๊ธฐ๋ฐ€์ด๋‚˜ ๋ฏธ๊ณต๊ฐœ ์•„ํŠธ์›Œํฌ์—๋„ ์•ˆ์ „ํ•ฉ๋‹ˆ๋‹ค.

Base64๊ฐ€ Content Security Policy์— ์˜ํ–ฅ์„ ์ฃผ๋‚˜์š”?

์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—„๊ฒฉํ•œ img-src ๋””๋ ‰ํ‹ฐ๋ธŒ๋Š” ์ธ๋ผ์ธ ์ด๋ฏธ์ง€๊ฐ€ ๋กœ๋“œ๋˜๋ ค๋ฉด data URI๋ฅผ ํ—ˆ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(img-src 'self' data:). ์šด์˜ ํ™˜๊ฒฝ์—์„œ data URI์— ์˜์กดํ•˜๊ธฐ ์ „์— CSP ํ—ค๋”๋ฅผ ํ™•์ธํ•˜์„ธ์š”.