이미지를 데이터 URL로 HTML에 삽입하기
- 선택
- 체크
- 붙여넣기
You want to embed a small image directly in HTML or CSS without making it a separate file. A data URL is what you use. You can make one with "Use data URL format (data:…;base64,)" in Convert Files and Base64.
순서
- For "Direction", choose "File → Base64".
- With "Choose one file", choose the image file.
- Tick "Use data URL format (data:…;base64,)".
- A string like "data:image/png;base64,…" appears under "Base64 after conversion".
- Copy with "Copy result" and paste it into the HTML image's src.
Example of use
The form for pasting into HTML: put the string you made in the src of the image tag. It can also go inside url() of a CSS background image.
Advantages of data URLs
- No need to prepare the image as a separate file
- Less communication for loading images
- Completes in one file (such as email HTML)
Disadvantages of data URLs
- The character count becomes about 1.3 times the original
- The HTML gets long and hard to read
- The browser cannot cache the image
- Using the same image in several places adds the text each time
Images that suit
- Small icons (a few KB)
- Single-colour logos and small decorations
- Background patterns
Images that don't suit
- Photos
- Large images
- Images used many times
A guide to size
Generally images up to a few KB to a dozen or so KB are said to suit embedding. Larger ones are easier to handle as separate files.
예
Embedded a 2KB small icon in HTML for email. It could be displayed without attaching the image.
Common stumbling blocks
- Not displayed in email: some email software doesn't display data URL images.
- The HTML is too long to handle: don't use it for large images.
- The type doesn't match: check that the leading "image/png" part matches the image format.
Frequently asked questions
Can things other than images become data URLs?
Yes. PDFs, text and so on can also be data URLs. But the situations to use them are limited.
요약
Make only small images into data URLs and embed them. Keep large images as separate files.
“파일과 Base64 변환” 사용하기 (무료)함께 쓰면 좋은 도구
- 파일 해시(SHA-256) 확인: 파일의 해시를 계산하고 비교합니다.
- CSV와 JSON 변환: CSV와 JSON을 즉시 서로 변환합니다.
- ZIP 파일 만들기: 여러 파일을 하나의 ZIP으로 묶습니다.