DevTools Logo

Vue SFC Playground

Vue SFC Playground

Draft a Vue single-file component and inspect its blocks, props and scoped styles in your browser.

Runs in your browserOffline static preview
Try an example

App.vue source

Template, script setup and style blocks are analyzed locally. No compiler, runtime or network is involved.

Compiled component

0 blocks · 0 error(s)

No SFC source yet

Type a component or try the scoped counter example.

Examples

Scoped counter

Input
<button @click="count++">Count: {{ count }}</button> with const count = ref(0)
Output
Count: 0 in the preview, data-v- marker on the button

Interpolations use initial ref values; the event handler is stripped from static markup.

Props and emits

Input
defineProps({ title: String, count: { type: Number, default: 0 } })
Output
Props table with title and count; Emits tab lists save and close

Nested default objects are split correctly before the table is built.

Unclosed tag

Input
<div class="oops">Hello
Output
template line 2: Unclosed tag <div> in template

The diagnostic names the block and source line so the fix is obvious.

About this tool

Vue SFC Playground is a scratchpad for one App.vue component. Paste template, script setup and style blocks, then inspect the structure without scaffolding a Vite project or installing a compiler.

The analyzer reads defineProps, defineEmits, defineExpose and ref declarations from script setup. Props appear in a table with types, required flags and defaults; emits are listed with their payload annotations; refs supply the initial values used in the preview.

Template checks catch unclosed and mismatched tags, unbalanced interpolation braces and unsupported template languages. Style blocks are reported separately, with scoped blocks getting a stable data-v- id that is applied to the preview markup and rewritten into selectors.

This is an offline structural playground, not @vue/compiler-sfc. The preview is static HTML: directives, reactivity, child components and CSS modules are described but not executed. A fragment token lets you share the exact UTF-8 source with a teammate.

What this tool does not do

  • This is not @vue/compiler-sfc: templates are not compiled into render functions and no Vue application is mounted.
  • Directives, child components, CSS modules and v-bind() in styles are reported but not resolved.
  • Only one component per file is analyzed; duplicate blocks produce a warning and the first block is used.
  • The share token is plain base64url, not compressed, and is capped at 16 KB of UTF-8 source.
  • Everything runs locally; drafts are not uploaded, and browser refresh discards them unless you keep the share token.

How to use this tool

  1. Paste a component

    Type an App.vue file into the source panel or load one of the examples. Template, script setup and style blocks are detected automatically.

  2. Read the preview

    Open the Preview tab to see static markup with interpolated ref values and scoped data-v attributes. The scoped CSS is shown underneath.

  3. Inspect macros

    Switch to Props or Emits to see declarations read from defineProps, defineEmits, defineExpose and withDefaults.

  4. Fix diagnostics

    The Diagnostics tab lists every block-level error and warning with line and column. Compilation errors also appear as an actionable banner.

  5. Share the draft

    Open the Share tab, copy the fragment token and put it in a URL. The token round-trips the source byte-for-byte, including non-ASCII text.

Use cases

Draft a component shape

Sketch template and script setup together before moving the file into a real project.

Share a minimal repro

Encode a failing snippet in a URL fragment so a teammate can paste it into their own editor.

Check scoped styles

See the data-v- id on preview tags and in the rewritten selectors for each scoped style block.

Teach SFC structure

Show how macros map to a props table and emit list while discussing component APIs.

Supported SFC blocks

BlockWhat is read
<template>Tag balance, interpolations, directives
<script setup>defineProps, defineEmits, defineExpose, ref
<script>The same macro declarations
<style>CSS text and scoped flag
<style scoped>Stable data-v- scope id

Blocks are preserved verbatim; line and column numbers refer to the source as pasted.

Common mistakes

Mistake:Expecting click handlers and reactivity to work in the preview.

Fix:The preview is static markup by design. Use a real Vue runtime for interaction; this tool explains structure and gives initial values.

Mistake:Pasting a template with lang="pug" or styles with lang="scss".

Fix:Preprocessors are rejected with a plain-language message. Convert them to HTML and CSS before using the tool.

Mistake:Assuming type-only props are type-checked.

Fix:Generic defineProps declarations are parsed for names and optionality, but no TypeScript compiler runs.

Mistake:Sharing a large component through the URL fragment.

Fix:The share token has a 16 KB UTF-8 limit; larger sources are rejected so URLs stay usable.

Mistake:Using multiple components in one file.

Fix:Keep one component per SFC; extra blocks produce a warning and only the first of each kind is analyzed.

Frequently asked questions

Does it support script setup and compiler macros?

Yes for structural analysis. defineProps (array, object and type-only forms), defineEmits, defineExpose, withDefaults and ref declarations are read and shown in the Props, Emits and preview panes. defineModel is detected but not expanded. The tool does not run the real compiler, so complex TypeScript transforms are not evaluated.

Are scoped styles applied?

Scoped style blocks each get a stable data-v- id derived from the source. Preview opening tags receive that attribute and the CSS selectors are rewritten to match it. Plain and scoped blocks can be mixed in the same component; each is reported separately.

Which Vue version runs?

None — there is no Vue runtime in this tool. It analyzes the source text and renders a static HTML preview, which makes it useful for component shape and diagnostics but not for testing reactivity or runtime behavior.

Can I use multiple components?

Only one component per file is supported. Multiple template, script or style blocks are listed with a warning and the first block of each kind is used. Child components referenced by capitalised tags are flagged as unresolved rather than silently ignored.

Is compilation server-side?

There is no compilation service at all. Parsing, macro extraction, checks and the preview run in your browser tab. Nothing is uploaded, and there is no account or draft database.

Why are my Pug template or SCSS styles rejected?

The analyzer supports plain HTML templates and plain CSS only. Preprocessors need a build step, which would require bundling a compiler. The diagnostic states which block and language are unsupported so you can convert the snippet first.

What does the share token contain?

It is the UTF-8 source encoded as base64url and placed in the URL fragment. It round-trips non-ASCII text byte-for-byte and is capped at 16 KB. The page reads it locally; no server ever sees the token.

Why don't @click or v-if do anything in the preview?

The preview is sanitized static markup: event handlers and bindings are stripped and directives are reported as warnings. This keeps arbitrary code from executing while still showing the markup shape, interpolated values and scoped-style markers.

References & standards