Introducing a new way to review your PRs.

Read the announcement

glincker / thesvg

The open SVG brand library: 7,600+ brand logos and cloud icons (AWS, Azure, GCP) as official SVG. Search, copy, ship via npm, CDN, CLI, React, Vue, Svelte, Figma, VS Code, Raycast and MCP. Free, MIT, no gatekeeping.

View on GitHub

27 documents · Updated Nov 23, 2026

docs / svg-viewer-and-conversion

SVG viewer and conversion

The SVG viewer and conversion tools let an engineer or creator bring an SVG into the browser, check what it contains, and move it into another tool or file format. The flow supports pasted and dropped files, catalog icons, editor hand-offs, code-format copies, SVG downloads, and pixel-image exports without sending viewer input to a server.

Asset flow

An asset can start as pasted XML, a local file, or an icon selected from the catalog. The viewer keeps that source in the browser, validates it before rendering, and sends the same asset to copy, download, editor, or conversion actions.

flowchart LR
    A[Paste SVG] --> D[Viewer source]
    B[Drop or upload file] --> D
    C[Select catalog icon] --> D
    D --> E[Validate and inspect]
    E --> F[Preview]
    E --> G[Format or minify]
    E --> H[Copy or download SVG]
    E --> I[Open in editor]
    J[Selected icon variant] --> K[Format copy]
    J --> L[PNG or raster export]

Viewer experience

Input and local state

The viewer accepts SVG text from a paste, a drag-and-drop or file-picker upload, and a catalog import. Local uploads are limited to 2 MB and must look like an SVG document before the viewer accepts them. The page states that this work stays in the browser and is not uploaded. src/…/page.tsx• L71-101 src/…/svg-viewer.tsx• L41-57 src/…/svg-viewer.tsx• L122-143

The viewer also accepts a catalog deep link such as /viewer?from=<slug>. It resolves the slug through the icon manifest, fetches the default variant, and uses the icon title for later file names and editor actions. A missing slug or failed fetch leaves an error instead of filling the editor with an invalid response. src/…/svg-viewer.tsx• L59-93

References: src/…/page.tsx• L71-101 src/…/svg-viewer.tsx• L41-57 src/…/svg-viewer.tsx• L59-93 src/…/svg-viewer.tsx• L122-143

Inspection and preview

The viewer treats the editor source as valid only when it passes its basic SVG shape check and XML parse. Valid input produces a live preview. The preview can use a checker, light or dark background so transparent artwork is easy to inspect.

The file information panel shows byte size, viewBox, width, height, element count, gradients and masks or clips. Invalid or empty input does not render and keeps the viewer's copy and download actions disabled. Before source text is inserted into the preview, the viewer removes high-risk active content such as scripts, event handlers, unsafe links and embedded HTML. src/…/svg-viewer.tsx• L95-105 src/…/svg-viewer.tsx• L389-485 src/…/svg-utils.ts• L8-46 src/…/svg-utils.ts• L127-161

References: src/…/svg-viewer.tsx• L95-105 src/…/svg-viewer.tsx• L389-485 src/…/svg-utils.ts• L8-46 src/…/svg-utils.ts• L127-161

Source cleanup

Format and Minify change the source in the viewer so a person can read or reuse the XML more easily. Format adds two-space indentation around XML nodes. Minify removes extra whitespace between tags and around attributes. These actions apply only after the source is valid. src/…/svg-viewer.tsx• L193-201 src/…/svg-utils.ts• L54-125

References: src/…/svg-viewer.tsx• L193-201 src/…/svg-utils.ts• L54-125

Catalog reuse

Quick import

Quick import connects the viewer to the catalog without making the user find and copy an icon file first. It loads the icon manifest, searches slugs, titles and aliases, shows up to eight matches, and fetches the selected icon's default SVG into the viewer. Starter buttons provide a short path to common icons. src/…/quick-import.tsx• L9-24 src/…/quick-import.tsx• L26-107

The search also supports keyboard selection with the arrow keys and Enter. A failed icon request is not passed to the viewer as source text, which prevents an HTML error page from being treated as SVG. src/…/quick-import.tsx• L86-127

References: src/…/quick-import.tsx• L9-24 src/…/quick-import.tsx• L26-107 src/…/quick-import.tsx• L110-127

A deep-link action is an action that moves the current SVG into an external editor or code playground. The shared target list defines six destinations and the hand-off type for each one:

  • CodePen and JSFiddle open a new page with the SVG placed in HTML.
  • Filagram opens a partner SVG viewer for editing, optimization or conversion.
  • Figma and Sketch copy the SVG so the user can paste it into a canvas or artboard.
  • Illustrator downloads an SVG for opening in Illustrator or Photoshop.

The viewer exposes these actions in a stack. An icon detail page exposes the same targets in its Open in editor menu. When the action starts from a catalog icon, the menu can pass the public SVG URL to Filagram so the partner can preload it. A pasted or uploaded asset has no public source URL, so the partner opens without preloaded content. src/…/svg-utils.ts• L163-217 src/…/svg-utils.ts• L238-327 src/…/deep-link-actions.tsx• L106-161 src/…/open-in-editor-menu.tsx• L86-205

References: src/…/svg-utils.ts• L163-217 src/…/svg-utils.ts• L238-327 src/…/deep-link-actions.tsx• L106-161 src/…/open-in-editor-menu.tsx• L86-205

Format copy

Format copy turns the selected catalog variant into a form suited to a target workflow. The icon detail code block offers the raw SVG plus JSX, Vue, CDN URL and data URI forms. The format choice changes the copied value while the selected variant remains part of the result. src/…/copy-formats.ts• L1-60 src/…/code-block.tsx• L27-71

The same catalog detail page also offers quick copies for the CLI command and CDN URL. These actions make the asset reusable in a project without first downloading it. src/…/quick-commands.tsx• L13-75

References: src/…/copy-formats.ts• L1-60 src/…/code-block.tsx• L27-71 src/…/quick-commands.tsx• L13-75

SVG downloads

The viewer can copy valid source text to the clipboard or download it as an SVG file. Catalog detail pages use the active variant and a stable name based on the icon slug. They also offer a data URI copy path for places that accept an inline image source. src/…/svg-viewer.tsx• L162-186 src/…/download-menu.tsx• L66-87 src/…/download-menu.tsx• L187-240

References: src/…/svg-viewer.tsx• L162-186 src/…/download-menu.tsx• L66-87 src/…/download-menu.tsx• L187-240

SVG conversion

PNG export

PNG export turns an SVG into a pixel image at a chosen square size while keeping the SVG aspect ratio. The icon detail page presents 32, 64, 128, 256 and 512 pixel choices. It exports the active variant and names the file with the icon slug, variant and size. src/…/png-export.tsx• L9-52 src/…/png-export.tsx• L55-105

The broader download menu uses the same conversion rules for PNG, JPG and WebP at sizes from 32 through 1024 pixels. JPG output uses a white background because it cannot keep transparency. The conversion utility accepts either raw SVG text or a source URL, checks that the XML can be parsed, preserves the aspect ratio from viewBox or dimensions, and reports conversion errors to the calling surface. src/…/svg-to-png.ts• L6-105 src/…/svg-to-png.ts• L107-203 src/…/download-menu.tsx• L35-47 src/…/download-menu.tsx• L89-117 src/…/download-menu.tsx• L243-299

References: src/…/png-export.tsx• L9-52 src/…/png-export.tsx• L55-105 src/…/svg-to-png.ts• L6-105 src/…/svg-to-png.ts• L107-203 src/…/download-menu.tsx• L89-117 src/…/download-menu.tsx• L243-299

Shared SVG utility

The shared SVG utility is the common boundary for recognizing, measuring, cleaning, formatting and reusing SVG text. It serves both the standalone viewer and icon detail actions, so changes to its rules can affect preview safety, source cleanup, editor hand-offs and file reuse at the same time. src/…/svg-utils.ts• L1-6

The conversion utility is separate because it produces pixel files rather than SVG text. It uses the same source-or-URL model and aspect-ratio expectations for its PNG and other raster outputs. src/…/svg-to-png.ts• L1-4 src/…/svg-to-png.ts• L115-125

References: src/…/svg-utils.ts• L1-6 src/…/svg-utils.ts• L19-46 src/…/svg-utils.ts• L61-161 src/…/svg-to-png.ts• L1-4 src/…/svg-to-png.ts• L115-125

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the viewer's accepted input rules, error states and render-cleaning rules aligned when changing source handling in svg-viewer.tsx or svg-utils.ts.
  • Keep the icon manifest's slug and variant paths aligned with quick import and the /viewer?from=<slug> deep link.
  • Keep DEEP_LINK_TARGETS, openDeepLink, the viewer action list and the icon detail menu aligned so each target has one clear hand-off behavior.
  • Keep copy format names and variant URL naming aligned across copy-formats.ts, the code block and quick command surfaces.
  • Keep raster format names, size choices, file extensions and aspect-ratio behavior aligned across svg-to-png.ts, PngExport and DownloadMenu.
  • Preserve the public SVG URL contract used to preload catalog assets in Filagram.

Important failure modes

TriggerConsequenceGuard
A pasted or uploaded value is not a likely SVG or does not parseThe preview stays empty or shows an invalid state. Copy, download and editor actions remain unavailable in the viewer.Validate before render and gate actions on valid metrics.
A local file is larger than 2 MBThe viewer rejects the file before reading it.Keep the file-size limit visible in the upload error path.
A from slug is absent from the manifest or its variant fetch failsThe viewer cannot preload the catalog asset.Show the load error and leave the editor source unchanged.
Clipboard access is deniedRaw copy, Figma or Sketch hand-offs cannot complete.Surface the clipboard error or action message so the user can use download instead.
An SVG has invalid XML, cannot load as an image, or the browser has no canvas contextPNG or raster export fails and no output file is produced.Catch conversion errors and let the user retry with another variant.
An SVG has no usable viewBox and no positive width and heightConversion uses a square output at the requested size.Add usable dimensions when source fidelity requires a non-square result.

Key files

FileWhy to read it
src/…/page.tsxDefines the standalone viewer page and its local-only product boundary.
src/…/svg-viewer.tsxShows the end-to-end viewer state: input, validation, preview, inspection, copy, download and action hand-offs.
src/…/quick-import.tsxShows how catalog search becomes viewer source text.
src/…/deep-link-actions.tsxShows the viewer-facing presentation of external editor actions.
src/…/svg-utils.tsDefines the shared SVG checks, metrics, source cleanup, formatting and deep-link contracts.
src/…/copy-formats.tsDefines the reusable SVG, JSX, Vue, CDN and data URI outputs.
src/…/code-block.tsxShows how format-copy is presented on an icon detail page.
src/…/open-in-editor-menu.tsxShows how a selected catalog variant reaches external tools or the standalone viewer.
src/…/svg-to-png.tsDefines browser-side PNG and raster conversion and download behavior.
src/…/png-export.tsxShows the focused PNG size choices on the icon detail page.
src/…/download-menu.tsxShows the combined SVG, data URI, PNG, JPG and WebP export surface.

For the wider product relationship, read SVG tools and creator workflows. For contribution gates that apply before an SVG enters the catalog, read Icon submission and validation.