Tag: Web

  • Image to Base64 Converter: Data URL Encoder [2026]

    Image to Base64 Converter: Data URL Encoder [2026]

    TL;DR: An image-to-Base64 converter encodes any image (PNG, JPG, WebP, SVG, GIF) as a Base64 string and wraps it in a data:image/;base64,... URL, ready to paste into HTML src, CSS url(), or JSON. Use it for inline icons under 4 KB, email templates that demand inline assets, and small SVGs that don’t justify a network request. Our free image-to-Base64 converter runs entirely in your browser — drag and drop any image, copy the result.

    A Base64 data URL inlines an image directly into HTML, CSS, or JSON. Instead of <img src="logo.png"> with a network request, you write <img src="data:image/png;base64,iVBORw0KGgo..."> and the image is part of the document. That eliminates the round-trip — useful for tiny icons in critical CSS, email templates that demand inline assets (Gmail blocks externally-hosted images by default), and JSON payloads where a separate file isn’t an option (push notifications, web push payloads, embedded widget configs).

    Our image to Base64 converter handles every common format, runs in your browser (the file never uploads), and gives you four output shapes — raw Base64, full data URL, CSS url(), and HTML <img> tag. This guide covers when inlining is the right call (often it isn’t), the size overhead (~33%), and the gotchas with caching, gzip, and font-icon migration.

    When to inline an image as Base64 — and when not to

    Use case Inline as Base64? Why
    Icon under 4 KB in critical CSS Yes Saves a request on the critical path
    HTML email template Yes (often required) Most clients block external images by default
    Large hero image (> 50 KB) No Inflates HTML, blocks parsing, no CDN caching
    Image used on every page No External file caches once, serves N times
    SVG icon set used 5+ times per page Maybe — try SVG sprite first Sprite sheets compress better than per-icon Base64
    Embed widget configuration JSON Yes JSON can’t reference external files
    Push notification icon Yes Browser push payloads are limited and need self-contained data

    The 33% size penalty

    Base64 encodes 3 raw bytes as 4 ASCII characters. That’s a 33% size overhead before any other effects. A 12 KB PNG becomes a ~16 KB Base64 string. For text-mode HTTP responses (HTML, CSS, JSON), gzip compresses the Base64 string back down — typically to within 5–8% of the original binary size. So the true overhead in a gzipped HTTP response is small.

    What gzip can’t fix: Base64-inlined assets are part of the HTML, so they block the HTML parser longer. They can’t be cached separately by the browser — every page load redownloads the whole HTML including the inline image. For an icon shown on every page, this trades a one-time round-trip for a recurring kilobyte penalty. Run the math.

    How to convert an image to Base64

    1. Open the image to Base64 converter
    2. Drop your image, click to pick a file, or paste from clipboard
    3. The converter detects the MIME type automatically (image/png, image/jpeg, image/svg+xml, etc.)
    4. Pick output format: Raw Base64, Data URL, CSS url(), or HTML <img> tag
    5. Click Copy — paste into your HTML, CSS, or JSON

    Output shapes — paste-ready for every context

    The same image produces four different output strings depending on where you’ll paste it:

    // Raw Base64
    iVBORw0KGgoAAAANSUhEUgAA...
    
    // Data URL — works in HTML src, CSS url(), JS Image()
    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
    
    // CSS url()
    .icon { background: url("data:image/png;base64,iVBORw...") no-repeat; }
    
    // HTML img tag
    <img src="data:image/png;base64,iVBORw0KGgo..." alt="...">

    Common gotchas

    • SVGs can be inlined more efficiently as URL-encoded SVG. Instead of data:image/svg+xml;base64,... use data:image/svg+xml;utf8,... with URL-encoded SVG markup. The result is smaller (no Base64 overhead) and gzip-compresses better. Most modern browsers support both forms.
    • Don’t inline JPEGs above ~10 KB. The Base64 string bloats your HTML by 33%, blocks the parser, and the savings from one fewer request are negligible compared to the parsing cost. Use a CDN.
    • Gmail strips inline Base64 PNGs above 4 KB in some cases. Email-client behaviour varies wildly; test with Litmus or Email on Acid before mass-mailing a campaign that depends on inline images.
    • CSP headers may block data URLs. A Content Security Policy with img-src: 'self' blocks data: URLs. Add data: to img-src if you use inline images: img-src 'self' data:;.
    • Don’t inline animated GIFs as Base64. Encoded GIF blobs are huge (often 100 KB+ for a 5-second clip), and most email clients render the first frame only anyway. Use a hosted MP4 or animated WebP for non-email contexts.
    • Build pipelines do this automatically. Webpack’s asset/inline, Vite’s ?inline import suffix, and Next.js’s next/image all auto-inline assets below a threshold. For a real codebase, configure that threshold in your bundler instead of running this tool by hand.

    When NOT to use this tool

    If your build pipeline (Webpack, Vite, Parcel, Next.js, Astro) handles inlining automatically — set the threshold in your bundler config and trust it. For batch automation in CI, write a Node script that reads the image and outputs the data URL — no browser needed. For SVG-heavy use, prefer SVG sprite sheets or inline <svg> markup over data URLs — they compress better and remain editable. Use this browser tool for one-off conversions, email templates pasted into Mailchimp/SendGrid, embed-widget config files, and learning what a data URL looks like.

    Frequently asked questions

    What’s the file size limit?

    Effectively your browser’s available memory. Conversion is fast for files up to several MB. Above 10 MB the Base64 string itself becomes unwieldy to paste. There’s no point inlining an image that large — use a CDN.

    Why does my Base64 string differ between tools?

    Same input bytes always produce the same Base64. Differences come from MIME type detection, line-break formatting (some tools insert \n every 76 characters per RFC 2045; modern tools output unbroken strings), or trailing padding. The encoded image bytes are byte-identical.

    Will inlining help my page load faster?

    For tiny critical-path images (under 4 KB, used once), yes — saves a network round-trip. For images used on multiple pages or above 10 KB, no — you bloat HTML with no caching, which is usually worse than a single fetch. Test with Lighthouse before committing.

    Does this work for SVGs?

    Yes, but a URL-encoded SVG (data:image/svg+xml;utf8,...) is usually smaller than Base64. Our converter offers both forms — pick “URL-encoded” for SVGs to save a few bytes.

    Is my image uploaded?

    No. The converter runs in your browser using the FileReader API. The image is loaded into memory and encoded locally — it never leaves your device. You can verify in the Network tab: dropping a file produces zero outbound requests.

    Can I decode Base64 back to an image?

    Yes — paste a data URL into the converter and toggle “Decode mode”. The original image is reconstructed and offered as a download. Useful for inspecting an inlined asset you want to extract from a page.

    Related tools and guides

     

  • CSS Triangle Generator: Border Trick + Clip-Path [2026]

    CSS Triangle Generator: Border Trick + Clip-Path [2026]

    TL;DR: CSS triangles use one of two techniques: the classic border trick (a zero-size element with thick transparent borders, where one border has a color — that color shows as a triangle) or modern clip-path with a polygon(). Border trick has perfect browser support back to IE 6; clip-path is cleaner CSS but needs a real-sized box. Our free CSS triangle generator outputs both forms with size, color, and direction controls.

    CSS triangles solve a specific problem: drawing a small triangular shape (tooltip arrows, dropdown indicators, breadcrumb separators, accent shapes) without an SVG or image. The two techniques have been around forever — the border-trick variant is famously hacky CSS that works because of how browsers render border miters at the corners of an element. The clip-path variant is straightforward but needs more recent browser support.

    Our CSS triangle generator builds either form. Pick a direction (up, down, left, right, or one of four diagonals), set size and color, and copy the production CSS. Both versions are inline-able — no extra HTML elements needed beyond the triangle’s own div or span. This guide explains both techniques, when to use which, and the rendering quirks that make one or the other choice for specific contexts.

    Border trick vs clip-path — which to use

    Technique Pros Cons
    Border trick Universal browser support; zero-size element Hard to gradient-fill; smaller hit area
    clip-path polygon() Cleaner CSS; can have content; gradient-fillable Modern only; needs real-size box

    For tooltip arrows and dropdown indicators (decoration only): use the border trick. For triangular badges, decorative shapes, or any triangle that needs gradients, text inside, or animation: use clip-path.

    The border-trick technique explained

    An element with width: 0; height: 0; and thick borders renders as four diagonal-mitered triangles meeting at the centre. Make three of those borders transparent and you’re left with a single triangle in the colour of the visible border:

    /* Triangle pointing up — 30px wide, 20px tall */
    .triangle-up {
      width: 0;
      height: 0;
      border-left: 15px solid transparent;
      border-right: 15px solid transparent;
      border-bottom: 20px solid #635BFF;
    }
    
    /* Triangle pointing down */
    .triangle-down {
      width: 0;
      height: 0;
      border-left: 15px solid transparent;
      border-right: 15px solid transparent;
      border-top: 20px solid #635BFF;
    }

    The size is implicit: the triangle’s width is twice the border-left/right width (30px above), and its height is whatever the visible border thickness is (20px). To change direction, change which border is solid and which are transparent.

    The clip-path technique explained

    A real-sized div clipped to a polygon shape produces an editable, fill-able triangle:

    /* Triangle pointing up */
    .triangle-up {
      width: 60px;
      height: 60px;
      background: #635BFF;
      clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    }
    
    /* Add gradient or border easily */
    .triangle-gradient {
      width: 60px;
      height: 60px;
      background: linear-gradient(45deg, #635BFF, #00D4FF);
      clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    }

    Bonus: clip-path triangles can have text inside (it’s a real div), can be flex/grid containers, and can be animated. The cost is needing modern browser support (Chrome 23+, Firefox 54+, Safari 7+ — universal in 2026 except IE).

    How to generate a CSS triangle

    1. Open the CSS triangle generator
    2. Pick direction (up, down, left, right, top-left/top-right/bottom-left/bottom-right diagonals)
    3. Set width and height
    4. Pick color, plus a stroke for the clip-path version
    5. Toggle between Border trick and clip-path output
    6. Click Copy CSS

    When you’d use a triangle in real CSS

    • Tooltip arrows. A triangle pointing at the trigger element. The classic use — small (8–12px), border-trick, positioned absolutely against the tooltip body.
    • Dropdown carets. The little ▼ next to “More” buttons. Often replaced by SVG icons in modern UIs but still common in plain-CSS contexts.
    • Breadcrumb separators. The “›” between items. Often a real character, but a CSS triangle gives precise control over color and angle.
    • Speech-bubble pointers. Chat-bubble UIs use a triangle pointing at the speaker. Border trick or clip-path both work.
    • Decorative section dividers. A wide, flat triangle as a wedge between page sections. Use clip-path on a full-width div for this.
    • Custom badges. Triangular accent on the corner of a card. clip-path with text inside.

    Common gotchas

    • Sub-pixel rendering. Triangles smaller than 8px can look blurry on non-retina displays because the diagonal isn’t a clean pixel boundary. Either use larger triangles or accept slight anti-aliasing artefacts.
    • Background colour bleeds. The transparent borders in the border trick still occupy hit-test area. The visible triangle’s clickable region extends to the full bounding box, not just the visible part.
    • Inline element issues. A border-trick triangle on a <span> may render with line-height padding around it. Use display: inline-block or wrap in a container.
    • Right-to-left layouts. A triangle pointing “left” should flip to point “right” in RTL layouts. CSS logical properties (margin-inline-start etc.) help, but border-direction names don’t have logical equivalents — handle the flip manually with [dir="rtl"] selectors.
    • Animation cost. Border-trick triangles can be expensive to animate (changing border width triggers layout). clip-path triangles animate cheaply (transform-only).
    • Don’t try to gradient-fill a border-trick triangle. Borders take a single solid color. For gradients, use clip-path; for the border trick, use a wrapper element with the gradient and the triangle as a mask.

    When NOT to use a CSS triangle

    For complex shapes (chevron with rounded corners, triangular logos, multi-color triangles), use SVG inline — much more flexible. For a triangle with shadows, drop-shadow, or stroke effects, use clip-path with filter: drop-shadow(). For very tiny triangles (under 4px), consider Unicode characters (▲ ▼ ◀ ▶) which are font-rendered and crisp at small sizes. For animated character indicators (like a pulse arrow), an SVG with proper SVG animations is smoother than a CSS-only approach.

    Frequently asked questions

    Why does the border trick work?

    Browsers render borders with diagonal miters at corners. An element with zero width and height is just a point — the corners meet at the centre — and each border becomes a triangle pointing inward. Make three transparent and one solid coloured, and you see only the solid triangle.

    Which technique should I use?

    For tooltip arrows and small UI triangles: border trick (universal support, simpler positioning). For decorative triangles with content, gradients, or animation: clip-path. Both are universally supported in 2026 except IE (retired).

    Can I make a triangle with rounded corners?

    Not with the border trick. With clip-path, the polygon corners are sharp by default — for rounded triangles, use SVG with stroke-linejoin or a custom path. There’s a CSS proposal for shape-radius but it’s not implemented yet.

    How do I rotate a triangle?

    For arbitrary angles, generate a “pointing-up” triangle and apply transform: rotate(45deg). The triangle rotates around its centre. Combine with transform-origin to rotate around a different point.

    Is my data uploaded?

    No. The generator runs in your browser. Triangle settings, the live preview, and the generated CSS stay on your device.

    Can I have text inside a CSS triangle?

    Yes — only with the clip-path version. The border-trick triangle has zero width and height, so no content fits. clip-path triangles are real divs with full layout properties — text, flex, grid, anything.

    Related tools and guides

     

  • HTML Minifier: Compress HTML Safely in Browser [2026]

    HTML Minifier: Compress HTML Safely in Browser [2026]

    TL;DR: An HTML minifier removes whitespace, comments, redundant attribute quotes, and (optionally) minifies inline <style> and <script> blocks. Typical pages shrink 20–35% pre-gzip. Use it on static pages, email templates, and AMP documents — but skip it on server-rendered HTML where bytes matter less than build complexity. Our free HTML minifier runs html-minifier-terser in your browser with safe defaults you can override.

    HTML is the easiest place to leave bytes on the floor. Hand-authored markup carries indentation, comments, optional closing tags (</li>, </p>), and quoted attributes that could be unquoted. A 112 KB hand-written page minifies to 78 KB (−30%); add gzip and you’re at roughly 18 KB on the wire. For a marketing landing page or an email template that ships unchanged for months, those savings compound across every visit.

    Our HTML minifier wraps html-minifier-terser — the de-facto Node.js engine since 2017 — and runs it entirely in your browser. It minifies inline CSS via csso and inline JS via Terser, both included. This guide covers what’s safe to strip, what to leave alone, and the gotchas that turn perfectly valid HTML into broken markup.

    What HTML minification removes (and the size impact)

    Transform Example Savings
    Collapse whitespace Indentation between tags 10–25%
    Remove comments <!-- ... --> 2–8%
    Drop optional tags </li> at end of <li> 1–3%
    Unquote attributes id="x"id=x 1–2%
    Drop redundant attrs type="text" on <input> <1%
    Boolean attribute collapse disabled="disabled"disabled <1%
    Minify inline CSS csso on <style> blocks 3–10% (depends on CSS)
    Minify inline JS Terser on <script> blocks 3–8% (depends on JS)

    Safe vs aggressive: which options to enable

    html-minifier-terser exposes about 30 boolean flags. Most are safe; a handful change rendering or break edge cases. Our default preset turns on these safe options:

    • collapseWhitespace — strip indentation between tags. Won’t collapse whitespace inside <pre>, <textarea>, or content marked with white-space: pre.
    • removeComments — strip <!-- ... -->. Preserves IE conditionals (<!--[if IE]>) and lines marked with <!-- ! -->.
    • removeRedundantAttributes — drops type="text", method="get", etc.
    • collapseBooleanAttributeschecked="checked"checked.
    • minifyCSS + minifyJS — minify inline blocks.

    Options to enable only with care:

    • removeOptionalTags — drops </li>, </p>, </td>. Valid HTML5 but breaks XML-strict tooling and some legacy parsers.
    • removeAttributeQuotes — saves a few bytes but breaks if an attribute value contains spaces or special characters.
    • conservativeCollapse — preserves a single space at edges where collapsing might affect rendering. Safer but smaller savings.

    How to minify HTML in your browser

    1. Open the HTML minifier
    2. Paste your HTML or drop in an .html file
    3. Pick the preset: Safe (default), Aggressive, or Email-template-safe
    4. Click Minify — output appears with before/after sizes
    5. Copy or download as .min.html

    Email-template gotchas

    HTML emails are the wild west: Outlook 2016 still parses HTML4 with quirks, Gmail strips <style> blocks under certain conditions, and Apple Mail rendering disagrees with iOS Mail in subtle ways. Aggressive minification breaks emails in ways that don’t show up in DesktopGmail but break in Outlook. Use the Email-template-safe preset, which:

    • Keeps all attribute quotes (Outlook chokes on unquoted)
    • Preserves IE conditional comments (<!--[if mso]>)
    • Doesn’t drop optional tags
    • Doesn’t minify inline CSS (some clients require expanded CSS)
    • Preserves <!--[if !mso]> and mso-* proprietary attributes

    Test minified email templates with Litmus or Email on Acid before sending; visual inspection in Gmail web won’t catch Outlook breakage.

    Common gotchas

    • Whitespace inside <pre> and <textarea> is significant. Minifiers preserve it by default; verify your output if you’ve added unusual elements with white-space: pre styling.
    • Inline templates (Vue, Handlebars, JSX) can break. Whitespace between adjacent text nodes carries meaning in some templating languages. Minify the rendered output, not the template source.
    • Attribute order changes. Some minifiers reorder attributes alphabetically. If you have CSS or JS that depends on attribute order (rare but real), turn that off.
    • JSON-LD inside <script type="application/ld+json"> is preserved. Minifiers shouldn’t touch JSON-LD content, but a buggy minifier may strip its leading whitespace and break parsing. Verify schema validates after minifying.
    • Don’t minify HTML you’ll edit later. Minified HTML is unreadable. Keep the source, generate the minified output as a build artefact, and never commit minified HTML to your repo unless that’s your only deployment artefact.
    • Multi-byte characters get corrupted by some legacy minifiers. html-minifier-terser handles UTF-8 correctly. Older “html-tidy” tools strip emoji and non-Latin characters silently.

    When NOT to use a browser HTML minifier

    For server-rendered apps (Next.js, Nuxt, Remix, SvelteKit, Astro), HTML minification is automatic in production builds. For static site generators (Eleventy, Hugo, Jekyll), it’s a single config flag. For email templates, install html-minifier-terser locally and run it as part of your build with the email-safe preset baked in. Use this browser tool for one-off pages, snippets pasted from a CMS, AMP pages prepared by hand, and email templates you edit visually.

    Frequently asked questions

    Is minified HTML still valid?

    Yes — html-minifier-terser produces valid HTML5. Even with optional-tag removal, the output passes the W3C validator. The exception is removeAttributeQuotes, which produces non-quoted attribute values that some old browsers (IE6/7) don’t handle correctly. Stick to the safe preset for maximum compatibility.

    How much will gzip add on top of HTML minification?

    Roughly another 60–70%. A 78 KB minified HTML file gzips to about 22 KB. HTML compresses extremely well because of repeated tag names and attribute values. Always serve .html with Content-Encoding: gzip or br.

    Will minification break my Schema.org JSON-LD?

    No — html-minifier-terser preserves <script type="application/ld+json"> contents intact. The JSON inside is passed through unchanged. If your schema breaks after minifying, the issue is elsewhere — usually whitespace stripping outside the script tag concatenating two adjacent script blocks.

    Can I minify HTML emails for Mailchimp or SendGrid?

    Yes, but use the email-template-safe preset. Modern email clients tolerate minified HTML, but Outlook 2016 and earlier choke on unquoted attributes and missing optional tags. Test in Litmus before sending.

    Is my HTML uploaded?

    No. The minifier runs in your browser via WebAssembly. Pasted markup never reaches our servers — useful when minifying pre-release pages, internal docs, or email templates with proprietary content.

    What’s the difference between an HTML minifier and a CSS minifier?

    HTML minifiers strip whitespace and tags from markup; CSS minifiers strip whitespace and shorten selectors inside stylesheets. Our HTML minifier also minifies inline <style> and <script> blocks, so for a single HTML file with embedded CSS/JS, one pass through the HTML minifier handles everything.

    Related tools and guides

     

  • HTML Formatter: Beautify HTML with Prettier [2026]

    HTML Formatter: Beautify HTML with Prettier [2026]

    TL;DR: An HTML formatter (or “HTML beautifier”) takes minified, copied, or messy HTML and reformats it with consistent indentation, line wrapping, and attribute alignment. Use it on copied HTML you need to read or edit, AI-generated markup, or scraped pages. Our free HTML formatter uses Prettier 3 in your browser with full support for HTML5, Vue, Svelte, Angular, and Handlebars templates.

    Reading minified HTML is like reading a one-line essay — every tag and attribute is jammed together with no visual structure. Try to debug a layout issue or insert a new element and you spend more time finding your place than fixing the bug. A formatter restores the structure: each block-level element on its own line, nested elements indented, long attribute lists wrapped, and closing tags aligned with their opens.

    Our HTML formatter runs Prettier 3 in your browser. It auto-detects HTML5, Vue single-file components, Svelte, Astro, Angular, and Handlebars templates. Configurable: indent width, attribute-per-line wrap threshold, void-element style (<br /> vs <br>), and whether to wrap long lines. Paste any size, get clean output, copy or download.

    Prettier HTML options that matter

    Option Default When to change
    printWidth 80 100–120 if you have many attributes per element
    tabWidth 2 4 only if matching legacy code
    htmlWhitespaceSensitivity “css” “strict” if rendering depends on inline whitespace
    singleAttributePerLine false true for very wide attribute lists
    bracketSameLine false true to keep > at end of last attribute line
    endOfLine “lf” “crlf” only for Windows-only repos

    The whitespace-sensitivity setting (the option you’ll actually want to think about)

    HTML treats whitespace inconsistently. Inside a <p>, multiple spaces collapse to one. Inside a <pre>, every space is preserved. Between two inline elements (<span>a</span> <span>b</span>), the space between affects layout. Prettier’s htmlWhitespaceSensitivity option controls how aggressively the formatter rearranges whitespace:

    • “css” (default): respect CSS display defaults. Block-level elements get their own lines; inline elements stay on the same line where whitespace would matter. Best for most modern pages.
    • “strict”: never break a line where doing so would add or remove whitespace that affects rendering. Safest but produces longer lines.
    • “ignore”: format aggressively, ignoring the impact on rendering. Use only if you control the CSS and know your inline elements have white-space rules that override the default.

    Most pages format cleanly with the default. If you see layout shifts after formatting, switch to “strict” and reformat.

    How to format HTML in your browser

    1. Open the HTML formatter
    2. Paste your HTML or drop in a .html file
    3. Pick the parser (auto-detect usually works): html, vue, angular, handlebars, svelte
    4. Adjust print width and tab width to match your project
    5. Click Format — output appears with syntax highlighting
    6. Copy or download

    Templating-language support

    Prettier handles plain HTML, but real codebases often have templating syntax mixed in. Prettier 3 supports:

    • Vue: single-file components (.vue) with <template>, <script>, <style> blocks formatted independently.
    • Svelte: .svelte files including {#if} / {#each} blocks and reactive declarations.
    • Angular: *ngIf, *ngFor, and binding syntax ([prop], (event)) preserved.
    • Handlebars / Mustache: {{…}} and {{#each}} blocks indented like HTML elements.
    • Astro: via the prettier-plugin-astro plugin.

    For JSX (React), use the JavaScript Formatter instead — JSX lives in JS files and the JS parser handles both.

    Common gotchas

    • Whitespace inside <pre> and <textarea> is preserved. Prettier doesn’t touch their content. If yours looks wrong, the issue was already in your source.
    • Self-closing void elements: Prettier 3 outputs <br> (HTML5 default) not <br /> (XHTML). To force XHTML style, post-process or use a different tool — there’s no built-in option in Prettier 3.
    • Comments above tags get attached to them. Prettier may move comments slightly to keep them tied to the right element. Usually fine; occasionally surprising.
    • Custom Web Components are formatted like regular HTML elements. A <my-button> with attributes wraps the same way <button> does. No special handling needed.
    • Don’t format AI-generated HTML and ship it without checking. AI tools sometimes produce <div>…<span>…</div> with mismatched tags; the formatter happily produces beautifully indented broken HTML. Validate with the W3C validator after formatting.
    • Inline event handlers stay inline. Inline on* attributes (on​click, on​load) aren’t reformatted. Use external script tags for anything non-trivial.

    When NOT to use a browser HTML formatter

    For a real codebase, install Prettier locally (npm i -D prettier), commit a .prettierrc, and configure your editor to format on save. That eliminates formatting drift between developers. Use this browser tool for one-off snippets, copied HTML from a CMS or AI assistant, scraped markup you need to inspect, and pages built without a build pipeline. Don’t run the formatter on minified production HTML and re-deploy — keep source and minified output as separate artefacts.

    Frequently asked questions

    What’s the difference between an HTML formatter and a beautifier?

    Same thing, different name. “Formatter” is the modern term (Prettier, dprint); “beautifier” is older (jsbeautify, HTML Tidy). Both reformat messy or minified markup into readable, indented output.

    Can I format Vue, Svelte, or Astro components?

    Yes. Prettier 3 handles Vue single-file components, Svelte files, Angular templates, and Astro components natively. Auto-detection picks the parser from file extension; you can override manually for paste-mode input.

    Will formatting change how my page renders?

    With the default htmlWhitespaceSensitivity: "css", no — Prettier respects CSS display rules and only adds whitespace where it doesn’t affect rendering. Edge cases involving custom white-space CSS may need htmlWhitespaceSensitivity: "strict" to be safe.

    Can I unformat (minify) HTML with this tool?

    No — formatting and minifying are opposite operations. For minification, use the HTML Minifier. Format while editing; minify before deploying.

    Is my HTML uploaded?

    No. Prettier runs in your browser via WebAssembly. Pasted markup never reaches our servers — useful for proprietary or pre-release pages.

    Can I save my Prettier config?

    Yes. Settings persist in your browser’s localStorage between sessions. There’s also a “Copy as .prettierrc” button that exports your settings as JSON ready to drop into a project root.

    Related tools and guides

     

  • URL Encoder/Decoder: Percent-Encode Safely [2026]

    URL Encoder/Decoder: Percent-Encode Safely [2026]

    TL;DR: URL encoding (also called percent-encoding) replaces unsafe characters in a URL with %XX hexadecimal escapes — for example, a space becomes %20, an ampersand becomes %26. Use it on query string values and path segments, not the whole URL. Our free URL encoder/decoder handles component-only and full-URL modes, fixes double-encoded strings, and is UTF-8 safe.

    URLs are constrained to a small set of ASCII characters. Anything else — spaces, accented letters, emoji, ampersands, plus signs, slashes inside a parameter value — must be percent-encoded so it survives transport through proxies, caches, and the URL parser at the destination server. Get the encoding wrong and your ?q=hello world becomes a mangled ?q=hello followed by an unparseable world token. Get the decoding wrong and a URL that contains a literal + shows up as a space.

    Our URL encoder and decoder covers both directions, distinguishes between component encoding (for query values and path segments) and full-URL encoding (for entire links), and detects double-encoded strings so you can recover the original cleanly. This guide explains exactly which characters need encoding under RFC 3986, when to use encodeURIComponent vs encodeURI in JavaScript, and the gotchas that produce subtle bugs in production.

    Reserved vs unreserved characters in RFC 3986

    Category Characters Encode in component?
    Unreserved A-Z a-z 0-9 - _ . ~ Never
    Reserved (gen-delims) : / ? # [ ] @ Yes, in component
    Reserved (sub-delims) ! $ & ' ( ) * + , ; = Yes, in component
    Space (space) Always — to %20 or + in form data
    Other ASCII " < > \ ^ ` { | } Always
    Non-ASCII (UTF-8) é, ü, 中, 🎉 Always — encoded byte-by-byte from UTF-8

    Component encoding vs full-URL encoding

    The most common mistake is encoding the entire URL when you should be encoding just one part of it. encodeURI in JavaScript is for whole URLs and preserves reserved characters like ?, &, #, and / because they have structural meaning. encodeURIComponent is for individual query values, path segments, or form fields and does encode those reserved characters because at that level they are just data.

    • Encode a query value: Use encodeURIComponent. ?q=hello world&safe=true becomes ?q=hello%20world&safe=true.
    • Encode a path segment: Use encodeURIComponent. /users/Jane Doe becomes /users/Jane%20Doe.
    • Encode an entire URL: Use encodeURI. The slashes and query separators stay intact; only spaces and unsafe characters get escaped.
    • application/x-www-form-urlencoded: Spaces become + instead of %20; otherwise identical to component encoding. This is the form-submission default.

    How to encode or decode a URL

    1. Open the URL encoder/decoder
    2. Paste your text or URL in the input
    3. Pick Encode component, Encode full URL, or Decode
    4. Output appears instantly; click Copy to clipboard
    5. If decoding produced unexpected results, click Decode again to handle double-encoded strings

    Double-encoding: the most common production bug

    Double-encoding happens when a URL is encoded twice somewhere in its journey — typically because an HTTP client encodes a value the framework had already encoded. The visible symptom: %2520 in the final URL where you expected %20 (a space). The % from the original %20 got encoded a second time to %25, which when concatenated with 20 reads as %2520.

    To fix: decode the string twice. Our tool detects the pattern automatically — if you paste a URL that decodes to another encoded URL, it offers a “decode again” button. The robust server-side fix is to encode at the boundary (where data leaves your code as a URL) and never in any layer above. Frameworks like Axios and Spring respect this by default; jQuery’s $.param and some legacy CMS pipelines do not.

    Common gotchas

    • Plus sign means space in form data, but not in URL paths. ?q=foo+bar decodes to foo bar in application/x-www-form-urlencoded; in a path segment, + stays as a literal plus. Our decoder respects the mode you pick.
    • Encoding the protocol breaks the URL. Never encode https:// — the colon and slashes are structural. Use encodeURI on the whole URL or just encode the parts that need it.
    • Tilde (~) is unreserved. Some old encoders escape it to %7E anyway. RFC 3986 says don’t. Our encoder leaves it alone.
    • UTF-8 is the only sane choice. Encoding emoji or Chinese characters produces multi-byte sequences (%E4%B8%AD for “中”). Servers must decode as UTF-8 — Latin-1 / ISO-8859-1 fallbacks corrupt the data.
    • Single quote (') is sub-delim. Encoded by encodeURIComponent to %27, but skipped by some legacy tools. Always include it in component encoding.
    • Hash fragment is encoded with the same rules as the path, not the query. Spaces become %20, not +.

    When NOT to use this tool

    If your code already runs encodeURIComponent on a value, do not paste the result here and click “Encode” again — you will produce double-encoding bugs. Use this tool to decode a URL you got from a log file, to encode values copied from a spreadsheet before pasting into a URL by hand, or to verify what a server is actually receiving. For programmatic encoding inside a build pipeline, use the language-native function (encodeURIComponent in JS, urllib.parse.quote in Python, URLEncoder.encode(s, "UTF-8") in Java).

    Frequently asked questions

    What’s the difference between encodeURI and encodeURIComponent?

    encodeURI assumes you have a full, structurally valid URL and only escapes characters that aren’t allowed anywhere in a URL. encodeURIComponent assumes the input is a single value (query parameter, path segment) and escapes all reserved characters. Use component for parts; use full only when you trust the input is already a valid URL skeleton with separators in the right place.

    Why does my URL show %2520 instead of %20?

    Double-encoding. A space was encoded to %20; then the whole string was encoded again, and the % became %25, producing %2520. Decode the URL twice to recover the original. The fix in code is to encode at exactly one layer of the request — never re-encode an already-encoded value.

    Should I encode my URL parameters before sending an HTTP request?

    If you build the URL with template literals or string concatenation, yes — wrap each parameter value in encodeURIComponent. If you use a library like fetch with the URL object and URLSearchParams, encoding is automatic. Don’t double up.

    How do I encode emoji or non-Latin characters?

    Use UTF-8 encoding (the default in JavaScript and Python 3). Emoji and Chinese characters are multi-byte sequences and produce strings like %F0%9F%8E%89 for 🎉 or %E4%B8%AD for “中”. Modern servers and CDNs handle this transparently; legacy IIS and some Java servlet stacks need explicit UTF-8 configuration.

    Is my URL data uploaded?

    No. The encoder/decoder runs in your browser via JavaScript. URLs and tokens you paste are never sent to our servers — useful for decoding tokens, signed URLs, or session strings without leaking them.

    What’s the difference between URL encoding and Base64 encoding?

    Different jobs. URL encoding makes a string safe to put inside a URL (only ASCII, only safe characters). Base64 makes binary data fit inside text-only formats like HTTP headers, email, or JSON. They are sometimes combined — a Base64-encoded JWT can still contain + and /, which need URL encoding (or use Base64URL, which substitutes - and _).

    Related tools and guides

     

  • HTML Entity Decoder & Encoder: Escape HTML Safely [2026]

    HTML Entity Decoder & Encoder: Escape HTML Safely [2026]

    TL;DR: An HTML entity decoder turns escape sequences like &lt;, &amp;, &#039;, and &quot; back into the original characters (<, &, ', "). The encoder does the reverse — replacing unsafe HTML characters with named or numeric entities so the browser renders them as text instead of parsing them as markup. Use our free HTML encoder/decoder to escape user input safely or recover content from a feed that arrived double-encoded.

    Every web developer eventually pastes a string from a CMS export, an XML feed, or a database column and sees &amp;quot;Hello&amp;quot; where they expected "Hello". That’s an HTML entity round-trip gone wrong. HTML escapes a small set of characters that have structural meaning — <, >, &, ", ' — into named entities (&lt;, &gt;, &amp;, &quot;, &#039;) so they appear as text rather than triggering tag parsing. Get the encoding right and your user-supplied content is rendered safely; get it wrong and you have either visible escape sequences or, worse, an XSS vulnerability.

    Our HTML encoder and decoder handles named entities (&eacute;, &copy;, &ndash;), numeric decimal entities (&#233;, &#169;), numeric hex entities (&#x00E9;), and the full HTML5 named-entity table (2,231 named entities). It runs entirely in your browser. This guide covers when to encode, the difference between named and numeric entities, double-encoding, and the XSS edge cases naive encoders miss.

    The 5 characters you must always escape — and 2 you should

    Character Named entity Numeric (decimal) Required in
    & &amp; &#38; Everywhere — encode first or you’ll double-encode
    < &lt; &#60; Text content — prevents tag injection
    > &gt; &#62; Text content (defensive — not strictly required)
    " &quot; &#34; Inside double-quoted attributes
    ' &#39; &#39; Inside single-quoted attributes (note: &apos; is HTML5 only)
    © &copy; &#169; Optional — only if not serving as UTF-8
    (em dash) &mdash; &#8212; Optional — only if not serving as UTF-8

    Named vs numeric vs hex entities

    You’ll see HTML entities in three forms in the wild. Named entities like &copy; are readable but only work for the ~2,231 characters that have an HTML5 name. Numeric decimal entities like &#169; reference the Unicode code point in base 10. Hex entities like &#xA9; reference the same code point in base 16. All three render identically.

    • Use named when readability matters and the character has a well-known name (&nbsp;, &copy;, &trade;).
    • Use numeric when you want maximum compatibility — every Unicode code point can be expressed numerically; not every character has a named entity.
    • Use hex when copying from a Unicode reference where code points are listed in hex (U+00A9&#xA9;). Hex is also more compact for high-codepoint characters.

    Important: &apos; for the single quote is HTML5-only. In HTML4 and XHTML 1.0 it’s not in the named-entity table — emails and old browsers may render it literally as &apos;. Use &#39; for maximum compatibility, especially in HTML emails.

    How to encode or decode HTML in your browser

    1. Open the HTML encoder/decoder
    2. Paste the string in the input box
    3. Pick Encode (text → entities) or Decode (entities → text)
    4. For encode, optionally toggle Numeric only to skip named entities (safer for emails and legacy clients)
    5. Click Copy to copy the output, or Decode again if the result still contains entity sequences (double-encoded data)

    XSS-safe context-aware encoding (what naive encoders miss)

    HTML entity encoding is not a one-size-fits-all defence against XSS. The right escape depends on where in the page you’re inserting user data. The OWASP-recommended split:

    • HTML body context: escape <, >, &. Inserting user text between tags.
    • HTML attribute context: additionally escape " (or ' if your attribute uses single quotes). Always quote your attributes; unquoted attributes are an injection vector.
    • JavaScript context: HTML entity escaping does not protect you here. Use JavaScript string escaping (< for <) or, better, JSON.stringify.
    • CSS context: use CSS hex escapes (\3C for <), not HTML entities.
    • URL context: use URL encoding (%3C for <), not HTML entities.

    Our encoder produces HTML-context escapes by default with an option for attribute-context (more aggressive). For JavaScript or URL contexts, use the URL encoder or escape inside JSON.

    Common gotchas

    • Encode the ampersand first. If you encode < to &lt; first, then encode & to &amp;, you’ll double-encode and end up with &amp;lt;. Always replace & first, then the rest.
    • Double-encoded feeds. RSS feeds, MailChimp exports, and CMS APIs sometimes encode their own escape sequences again. &amp;amp; means the original was & encoded twice. Decode twice to recover.
    • Non-breaking space looks like a space but isn’t. &nbsp; (U+00A0) is invisible but breaks string-equality checks. If your string compare fails despite identical-looking text, replace nbsp with regular space first.
    • Internet Explorer recognised non-standard named entities. Avoid &apos; in HTML emails for IE/Outlook compatibility — use &#39;.
    • Numeric entities work for any code point. Need a thumbs-up emoji? &#128077; works everywhere; the named entity does not exist.
    • UTF-8 makes most named entities unnecessary. If your page is served as charset=utf-8 (which it should be in 2026), you only need to escape &, <, >, ", and '. Don’t encode ©, , é — just write them directly.

    When NOT to use this tool

    For server-side templating, use your framework’s auto-escaping: React ({value} escapes by default), Vue, Handlebars, Jinja2, Thymeleaf, ERB, Liquid all escape HTML automatically. Only reach for an external encoder when you have a stuck string from a feed, log, or copy-paste of an export. For programmatic encoding in client-side JS, element.textContent = userInput is safer than building an HTML string and encoding it — the DOM API never confuses content with markup.

    Frequently asked questions

    What’s the difference between HTML entity encoding and URL encoding?

    Different places, different rules. HTML entity encoding makes characters safe to include inside an HTML document (&&amp;). URL encoding (percent-encoding) makes characters safe to put inside a URL (&%26). They are not interchangeable. Use HTML for HTML, URL for URLs.

    Why does my page show &amp;quot; instead of “?

    Double-encoding. The string was encoded once ("&quot;), then encoded again, so & became &amp; and the result is &amp;quot;. Decode twice to recover. Long-term fix: encode at exactly one layer of your stack — typically right before output, never during storage.

    Does my framework already escape HTML?

    Probably yes, if you use template syntax like React’s {value}, Vue’s {{ value }}, Jinja2’s {{ value }}, or Handlebars’s {{ value }}. All escape by default. The dangerous variants — React’s dangerouslySetInnerHTML, Vue’s v-html, Jinja2’s |safe — bypass escaping. Audit those carefully.

    Should I use named or numeric entities?

    Numeric is more universal. Named entities (&copy;) are readable but only ~2,231 characters have HTML5 names. Numeric entities (&#169;) work for every Unicode code point. For HTML emails, prefer numeric — old email clients may not recognise newer named entities like &apos;.

    Is my data uploaded?

    No. The encoder/decoder runs in your browser via JavaScript. Pasted content is never sent to our servers, which makes it safe for decoding tokens, signed cookies, or potentially sensitive feed data.

    How many named HTML entities exist?

    HTML5 defines 2,231 named character references. They cover the named entities from HTML4 plus many more — including math symbols, arrows, and Greek letters. Our decoder handles all of them. The full list is in the WHATWG HTML spec.

    Related tools and guides