Skip to main content
NeatUtility

SVG Viewer, Formatter & Sanitizer

XML & Markup100% Client-Side
Ready
XML
0 lines0 chars
0 B / 488.3 KB
About this tool, examples & FAQ

Clean, format, sanitize, and minify Scalable Vector Graphics markup with XSS removal, UTF-8 Data URI generation, and geometry inspection.

Key facts

Verified capabilities and limits of this utility
Vector specificationW3C Scalable Vector Graphics (SVG) 2 & OWASP File Upload Security
Sanitization scopeRemoves <script>, <foreignObject>, inline on* event attributes, and javascript: URIs
Data URI generationCreates lightweight UTF-8 encoded SVG data URIs for inline CSS without Base64 inflation
Max input size500 KB
Execution deadline2 s
Processing locationBrowser-only: SVG parsing, formatting, and sanitization executes in a local Web Worker

How to use

  1. Paste SVG XML markup or icon code into the editor.
  2. Select operation: Format & Clean, Minify SVG, Sanitize for Security, SVG Data URI, or SVG Metadata.
  3. Inspect the formatted vector hierarchy or review stripped malicious tags.
  4. Copy sanitized SVG or Data URI code directly for use in your templates.

Example

Format simple SVG vector markup

Input

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M12 2L2 22h20L12 2z" fill="#3b82f6"/></svg>

Example output

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
  <path d="M12 2L2 22h20L12 2z" fill="#3b82f6"/>
</svg>

Edge cases

Embedded JavaScript removal

Strips executable JavaScript from <script> tags and onclick/onload inline attributes to neutralize stored XSS vectors.

XML comment stripping

Removes verbose design tool comments (<!-- Generator: Adobe Illustrator... -->) to conserve bandwidth.

Percent-encoding in UTF-8 Data URIs

Percent-encodes '#' as '%23', '<' as '%3C', and '>' as '%3E' to ensure valid CSS background-image URL rendering without Base64 overhead.

How it works

  1. Tokenizes XML nodes and attributes into a hierarchical document tree.
  2. Applies security filters to strip active scripting elements and unsafe event hooks.
  3. Formats indentation or compresses redundant whitespace per selected operation.
  4. Extracts viewBox dimensions, path counts, and calculates compression ratios.

Frequently asked questions

Why do SVG files need to be sanitized?

SVGs are XML documents that can execute JavaScript through <script> tags or inline onload handlers. Sanitization prevents malicious script injection when rendering user-submitted avatars or vector badges.

Why use UTF-8 Data URIs instead of Base64?

Base64 encoding increases file payload size by ~33%. A UTF-8 data:image/svg+xml;utf8,... URI only needs minimal percent-encoding for reserved characters, remaining smaller and human-readable.

Is my SVG uploaded anywhere?

No. All SVG processing, sanitization, and minification runs strictly in your browser via a client-side Web Worker.

References