HTML Encoder/Decoder for TypeScript
Free online html encoder/decoder with TypeScript code examples
Working with html encoder/decoder in TypeScript? Our free online html encoder/decoder helps TypeScript developers format, validate, and process data instantly. Below you will find TypeScript code examples using he so you can achieve the same result programmatically in your own projects.
Try the HTML Encoder/Decoder Online
Use our free HTML Encoder/Decoder directly in your browser — no setup required.
Open HTML Encoder/DecoderTypeScript Code Example
import he from 'he';
const raw: string = '<script>alert("XSS")</script>';
const encoded: string = he.encode(raw);
console.log(encoded);
const decoded: string = he.decode(encoded);
console.log(decoded);Quick Setup
Library: he
npm install he @types/heTypeScript Tips & Best Practices
- Install @types/he for TypeScript definitions
- he.encode supports options like useNamedReferences
- Use he.escape() for minimal encoding (just &, <, >, ", ')