DevTools Logo

SVG Placeholder Generator

SVG Placeholder Generator

Generate placeholder images as SVG code, data URI, <img> snippet or CSS background — live preview, rounded corners, auto-fit label.

Font size auto-fits the label to the canvas.

#e2e8f0
#475569

Clamped to half the smaller side.

Canvas presets:
Font family:

Examples

OG banner mock

Input
1200×630, slate background, label "1200 × 630"
Output
<img src="data:image/svg+xml,…" width="1200" height="630" alt="1200 × 630" />

One snippet drops into a prototype before the real artwork exists — no service, no request, no broken image.

Inline CSS placeholder

Input
256×256 avatar canvas, format: CSS background
Output
.placeholder { background-image: url("data:image/svg+xml,…"); background-size: cover; }

The data URI rides inside the stylesheet — ideal for email templates where external images get blocked.

Contrast rescue

Input
Label #e2e8f0 on background #f8fafc
Output
warning: low contrast, ratio under 3:1

The check fires before export, so unreadable labels never reach a client review deck.

About this tool

Every mockup needs an image before the image exists. The usual reflex — placekitten.com/640/360 or another placeholder service — quietly couples your prototype to someone else's uptime, leaks every visitor's request to a third party, and breaks the moment the service goes away. The SVG Placeholder Generator produces the same gray box with a label as self-contained markup: an SVG string, a data URI, an <img> snippet or a CSS background rule, generated entirely in your browser with no network call at all.

The template is deliberately minimal and standard-compliant: a background rect with optional rounded corners (rx clamped to half the smaller side) and a centered label using text-anchor and dominant-baseline, so the text sits at the visual middle of any canvas without a font-measurement step. The label's font size auto-fits — it starts at about 16% of the smaller side and shrinks until the estimated text width fits 90% of the canvas — so "1200 × 630" and a long sentence both render legibly without manual tuning. Label text is XML-escaped before it enters the template, which means pasting markup into the label can never break the output.

Four export formats share one generated SVG. The raw code is what you paste into a component or design file; the data URI is the URL-encoded form that drops into <img src> or background-image with zero extra requests; the <img> snippet ships with width, height and an alt attribute ready for HTML prototypes; and the CSS rule wraps the data URI for background usage in stylesheets. A live preview renders the exact same data URI you copy, so what you see is byte-for-byte what you ship, and the character counter keeps data-URI weight visible for inline usage.

Color choices get a guardrail: the label color is checked against the background with the same WCAG contrast core the site's contrast tools use, and anything under the 3:1 large-text threshold triggers a warning before the placeholder ships to a client deck. Dimensions are clamped to a 1–4096 pixel budget — small enough to stay sane, large enough for print-scale mocks — and nothing about the canvas, colors or label ever leaves the device. When the real artwork arrives, the SVG Optimizer can slim production SVGs, and the SVG Previewer renders any SVG file side by side.

What this tool does not do

  • Output is a single rect plus a label — it is a placeholder, not a compositor: no gradients, patterns or multi-element scenes.
  • Label font rendering depends on the viewer's installed fonts; the font-family stack names the fallbacks you get.
  • The contrast check uses WCAG ratio math only — it does not replace the full APCA analysis in the dedicated contrast tool.

How to use this tool

  1. Set the canvas

    Enter width and height (1–4096 px), or use a preset chip for common sizes like a 1200×630 OG banner.

  2. Pick colors, label and corners

    Choose background and label colors, type the label (font size auto-fits), and add a corner radius if you want rounding.

  3. Watch the contrast bar

    Keep the label color at least 3:1 against the background — the warning clears once the pair is readable.

  4. Choose a format and copy

    Switch between SVG code, data URI, <img> snippet and CSS background; the preview shows the same data URI you copy.

Use cases

Prototyping layouts

Fill image slots in wireframes and UI mocks with exact-sized SVG boxes instead of waiting on artwork or a placeholder service.

Email-safe dummy images

Data URIs survive clients that block external images, so template mockups render everywhere on first open.

Design tokens and docs

Generate labeled canvas swatches for documentation — dimension, color and corner radius visible in one glance.

The four export formats

FormatUse it for
SVG codePasting into components, docs or design tools as editable markup
Data URIInline embedding in HTML or CSS with zero extra requests
<img> snippetDrop-in HTML with width, height and alt already set
CSS backgroundA .placeholder rule with background-image, size and position wired
Live previewRenders the identical data URI — what you see is what you copy

Dimensions clamp to 1–4096 px; the corner radius clamps to half the smaller side; labels are XML-escaped.

Common mistakes

Mistake:Pointing prototypes at placeholder services.

Fix:placekitten-style URLs couple your mock to someone else's uptime and leak visitor requests. Self-contained SVG data URIs render offline and never expire.

Mistake:Shipping near-invisible label colors.

Fix:A label within 3% luminance of the background is unreadable in review. Watch the contrast warning — 3:1 is the large-text floor.

Mistake:Forgetting data URIs have weight.

Fix:Every inline data URI inflates the HTML or CSS by its full encoded length. The character counter is there so you notice a 40 KB label before your email template does.

Frequently asked questions

Why use an SVG placeholder instead of a placeholder service?

A service like placekitten makes every page load depend on someone else's server: it leaks your visitors' requests to a third party, adds latency, and breaks images when the service is down or the domain dies. An SVG placeholder is self-contained — the markup or data URI ships inside your own HTML and CSS, renders offline, and never expires. For prototypes, emails and documentation, that reliability is usually the whole point.

How big is a data URI, and when does that matter?

The data URI is the URL-encoded SVG, typically a few hundred characters for a simple box — the tool shows the exact count. It matters when you inline many placeholders: every data URI inflates the HTML document or stylesheet by its full encoded length, which adds weight to emails and slows first render if you embed hundreds. For a handful of mock images the overhead is trivial; for bulk use, reference one SVG file instead of inlining each one.

How does the automatic font size work?

The label starts at roughly 16% of the smaller canvas side, then shrinks until the estimated text width — about 0.62 em per character — fits within 90% of the canvas width. "640 × 360" on a 640×360 canvas stays large, while a full sentence shrinks to fit. There is no font measurement step; the estimate keeps the SVG a pure string template that renders identically everywhere.

What does the contrast warning check?

It computes the WCAG contrast ratio between your label color and background color using the same core as the site's contrast tools, and warns below 3:1 — the WCAG large-text threshold, which placeholder labels comfortably exceed in size. Below that, the label is hard to read in reviews and screenshots. Raise the luminance difference between the two colors until the warning clears.

Is the corner radius always honored?

The radius is clamped to half of the smaller side — the SVG spec's own behavior for rectangles, where rx and ry larger than half the side get scaled down anyway. A 24 px radius on a 256×256 canvas renders exactly; a 500 px radius clamps to 128 px. Set it to 0 for sharp corners, and the rx attribute is omitted from the markup entirely.

Is the label text safe if I paste markup or symbols?

Yes — the label is XML-escaped before it enters the template: &, <, >, quotes and apostrophes become entities, so pasted markup renders as literal text instead of being parsed as SVG. The output stays a valid single-line SVG document, which is also what keeps the data URI clean: one line, fully URL-encoded, no raw newlines or unescaped hash signs to break CSS url() syntax.

References & standards