인코딩
XML Entities Encode/Decode
XML 엔티티 인코딩 및 디코딩 — 5가지 표준 엔티티(앰퍼샌드, 꺾쇠괄호, 아포스트로피, 따옴표) 및 숫자 문자 참조.
Unlike HTML, XML strictly requires escaping five special characters (&, <, >, ', "), or the document is considered invalid. This tool encodes and decodes those entities, as well as numeric character references.
How to use it
- Encode: paste text and the five reserved characters get replaced with their matching entities (&, <, >, ', ").
- Decode: paste XML containing entities to get plain text back.
- Numeric character references (& or &) are supported too, for characters outside the standard five.
Common uses
- Preparing user text for insertion into an XML document (an RSS feed, a SOAP request, a config file).
- Debugging why an XML parser rejects a document — often the cause is an unescaped ampersand or angle bracket inside the text.
- Decoding content received from an XML-based API to read it in its original form.
Things to keep in mind
XML parsers are much stricter than HTML: a single unescaped entity invalidates the entire document, not just one element.
CDATA sections (<![CDATA[...]]>) are an alternative to escaping for large blocks of text, letting you insert arbitrary content without replacing every special character individually.
자주 묻는 질문
XML 엔티티는 HTML 엔티티와 뭐가 다른가요?
XML은 lt, gt, amp, apos, quot 이렇게 단 5개의 이름 있는 엔티티만 표준으로 정의합니다. HTML은 같은 훨씬 많은 named entity를 지원하지만, XML에서는 이 5개 외의 문자는 숫자 문자 참조(& 등)로 표현해야 합니다.
왜 <, &, ' 같은 문자를 엔티티로 바꿔야 하나요?
이 문자들은 XML 문법에서 태그나 속성 구분자로 예약되어 있어서 그대로 두면 문서 구조가 깨지거나 파싱 오류가 납니다. 엔티티로 인코딩하면 이런 문자를 텍스트 값으로 안전하게 담을 수 있습니다.
입력한 XML/텍스트가 서버로 전송되나요?
아니요. 인코딩과 디코딩 모두 브라우저 안에서 처리되며 서버로 전송되는 데이터는 없습니다.
CDATA는 무엇이고 언제 엔티티 대신 사용해야 하나요?
<![CDATA[...]]> 섹션을 사용하면 < 와 & 를 이스케이프하지 않고 텍스트 블록을 삽입할 수 있어, XML 안에 담긴 큰 코드나 HTML 조각에 편리합니다. 예외는 CDATA를 닫는 ]]> 시퀀스로, 이는 섹션 내용 자체에는 나타날 수 없습니다.
XML 파서는 유효하지 않은 엔티티를 모두 똑같이 처리하나요?
아니요. HTML을 "너그럽게" 봐주는 브라우저와 달리 XML 파서는 엄격합니다: 이스케이프되지 않은 앰퍼샌드나 꺾쇠괄호 하나만 있어도 문서 전체가 유효하지 않게 되어 처리가 오류와 함께 중단됩니다.