DevTools Logo

SVG Previewer

Advanced SVG Previewer

Professional SVG editor with live preview, validation, optimization, and comprehensive analysis

Editor & Settings

    Examples

    Remove script and event-handler markup

    Input
    <svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"><script>alert(2)</script><circle r="8"/></svg>
    Output
    <svg xmlns="http://www.w3.org/2000/svg"><circle r="8"/></svg>

    With sanitization enabled, the component removes the script element and the quoted onload attribute before previewing or copying the SVG.

    Minify spacing between elements and attributes

    Input
    <svg width = "20" height = "10">
      <rect width = "20" height = "10" fill = "blue" />
    </svg>
    Output
    <svg width="20" height="10"><rect width="20" height="10" fill="blue" /></svg>

    The minifier collapses whitespace, removes inter-element line breaks, and tightens spacing around equals signs.

    About this tool

    Advanced SVG Previewer is a browser-based SVG editor with live rendering, XML validation, optional formatting, simple minification, and basic sanitization. It supports side-by-side, editor-only, and preview-only layouts plus transparent, white, black, or checkerboard backgrounds and several preview size limits.

    The analysis panel counts characters, elements, attributes, paths, shapes, text, groups, gradients, patterns, and animation elements. It also reads numeric width and height attributes, reports the viewBox, estimates the Blob size, and assigns a complexity label from the component's element and character thresholds.

    Sanitization removes script elements, inline on-event attributes, and detected JavaScript or JavaScript-bearing data URLs. This is a limited preview safeguard rather than a complete security boundary for arbitrary hostile SVG.

    How to use

    1. Load or enter SVG

      Edit the initial sample, choose one of the built-in examples, paste markup, or load an .svg or .xml file.

    2. Configure processing

      Enable or disable sanitization, real-time validation, XML re-serialization formatting, and whitespace minification.

    3. Tune the preview

      Choose the editor layout, preview background, and fit, actual, 200 px, 400 px, or 600 px size constraint.

    4. Inspect and export

      Review validity and statistics, then copy the processed SVG or save it as a timestamped .svg file.

    Use cases

    Reviewing hand-written SVG

    Edit geometry or attributes while watching the browser render update alongside the markup.

    Inspecting design exports

    Count paths, shapes, groups, gradients, animations, attributes, and total elements in an exported asset.

    Testing backgrounds and dimensions

    Check transparency against multiple backgrounds and compare fit, actual, and constrained preview sizes.

    Preparing a compact SVG copy

    Apply the component's formatter or lightweight minifier before copying or downloading the processed markup.

    Common mistakes

    Mistake:Treating the built-in regex sanitization as a complete sanitizer for attacker-controlled SVG.

    Fix:Use a maintained, context-aware sanitization policy before embedding untrusted SVG in a production page.

    Mistake:Enabling formatting and minification together without realizing formatting runs first and minification then removes its added spacing.

    Fix:Choose the final representation you need and enable only the processing options that contribute to it.

    Mistake:Reading numeric width and height statistics as proof that the rendered dimensions are fixed.

    Fix:Also inspect viewBox, CSS, units, and the containing layout because the statistics only parse numeric width and height attributes.

    Mistake:Assuming the export-format state produces PNG, JPEG, or WebP files.

    Fix:Use the implemented Save action for SVG output; the current component exports processed markup as an .svg file.

    Frequently asked questions

    References & standards