b2KIT

SVG Code Editor & Live Preview

Edit SVG markup with live rendering, syntax highlighting, and instant preview.

How to Use SVG Code Editor & Live Preview

  1. 1

    Enter SVG code

    Type or paste your SVG markup in the code editor.

  2. 2

    See live preview

    Watch the SVG graphic update as you edit the code.

  3. 3

    Download the SVG

    Save the final SVG file for use in your project.

Tested tool guide Tested browser tools Checked August 16, 2026

What SVG Code Editor & Live Preview does, with a checked example

SVG is a text format: the code is the drawing, so the fastest way to work on one is to edit the code and watch it render. This tool puts a highlighted markup pane next to a preview pane that redraws on every change, following standard SVG rendering rules, so what you see is what a browser will draw. The first surprise most people hit: SVG has no layout. An svg element without width or height falls back to a 300 by 150 pixel canvas, and anything drawn outside it is clipped, not resized.

Worked example

A concrete input and expected output from the current implementation.

Input

<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <circle cx="100" cy="100" r="80" fill="#0A84FF" stroke="#000000" stroke-width="4"/>
</svg>

Expected output

The preview renders a 200 by 200 canvas with one shape: a solid #0A84FF blue circle, 160 units in diameter, centered in the frame. Its fill edges sit exactly 20 units from the left, right, top, and bottom. The 4-unit black stroke straddles the outline and paints 2 units beyond the radius on every side, so the outermost painted pixels fall at 18 and 182 units, inside the canvas, so nothing is clipped.

The render follows directly from the attributes: cx and cy place the center, r sets the radius, and the viewBox maps the 200-unit coordinate system onto the 200-pixel canvas one-to-one. The margins (200 minus 160, halved) and the stroke overhang (half of stroke-width) are plain arithmetic on those values.

How the result is produced

1

Whole-document re-render

Every change re-parses the full document, not just the edited line. SVG markup is XML, and XML well-formedness is all-or-nothing: one unclosed tag or unquoted attribute value invalidates the whole document, so a broken line can blank the entire preview, not only the element you touched. The same parse drives the syntax highlighting, so a structural mistake usually surfaces there first.

2

Canvas and coordinate system

width and height set the on-screen canvas; viewBox sets the coordinate system the drawing lives in, and the browser scales one onto the other. viewBox="0 0 200 200" on a 200-pixel canvas maps each user unit to one pixel; viewBox="0 0 100 100" on the same canvas doubles every coordinate. preserveAspectRatio decides how the drawing fits when the two aspect ratios differ: letterboxed, cropped, or stretched.

Good uses

  • Tuning a hand-written icon, logo, or diagram: adjust fills, stroke widths, radii, and path coordinates and confirm the geometry visually before committing the markup.
  • Debugging an SVG copied from a webpage, a design tool, or another codebase: check whether a missing viewBox, coordinates beyond the canvas, or a transform is pushing shapes off-screen.
  • Building an inline SVG from scratch and iterating on it: construct one element at a time, verify each step in the preview, then copy the finished code straight into HTML or a standalone .svg file.

Limits and checks

  • A blank or partial preview can be valid markup: omitting width and height gives a 300 by 150 default canvas (with only a viewBox, 300 wide with height from its aspect ratio), and anything outside that canvas is silently clipped, so the drawing may simply be off-canvas.
  • The preview is a render check, not a validator. Markup that works here - for example without an xmlns declaration or with unquoted attributes - can still fail as a standalone .svg file, which must be well-formed XML and should declare the SVG namespace.
  • Text renders with the fonts available to the browser. font-family is a request, not a guarantee: an absent family triggers substitution, so glyph metrics and spacing in the preview can differ from the machine that finally displays the file.

Common questions

My markup looks valid, so why is the preview blank?

Check two things. First, well-formedness: one unclosed tag or unquoted attribute anywhere invalidates the whole XML document, so nothing renders. Second, geometry: shapes drawn outside the canvas are clipped, so confirm your coordinates fall inside width, height, and viewBox. Removing elements one at a time isolates the culprit quickly.

What is the difference between width, height, and viewBox?

width and height set the canvas size; viewBox sets the coordinate system the drawing uses. With viewBox="0 0 100 100" and width="200", every user unit paints two pixels. With neither attribute, the canvas is 300 by 150 pixels; with only a viewBox, it is 300 wide and the height follows the viewBox aspect ratio, so "0 0 100 50" yields a 300 by 150 canvas.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools