tool

Vue Formatter & Validator

Format Vue single-file components – template, script and style – and check every block for syntax errors.

input
0 characters
1
result

paste your code and choose format

Format and validate Vue single-file components

Paste a complete .vue file and format all three parts at once: the <template> markup with its directives, the <script> or <script setup> block in JavaScript or TypeScript, and the <style> block in CSS, SCSS or Less. Validation checks the component structure and then parses each script and style block with the right parser, so a syntax error in a lang="ts" script is reported with its line number in the original file. It all runs in your browser.

What can you do?

  1. 1. Template formatting
    Indent nested elements and keep v-if, v-for, :bind and @event attributes readable, with {{ interpolations }} spaced consistently.
  2. 2. Script and script setup
    Format the script block as JavaScript or TypeScript depending on its lang attribute, including Composition API code with typed refs and props.
  3. 3. Scoped and preprocessed styles
    Format <style>, <style scoped>, lang="scss" and lang="less" blocks with the matching CSS parser.
  4. 4. Block-by-block validation
    Errors are reported per block, e.g. “<script> block – Line 12, column 10: Type expected”, with line numbers that match your original file.

Why format Vue components with one tool?

A single-file component mixes three languages. Formatting each part by hand, or with separate tools, is tedious and easy to get inconsistent. Prettier understands the whole file and applies the right rules to each block, which is why the official create-vue project scaffolding offers it as the formatter of choice.

It also matters for validation. When a script block contains a syntax error, Prettier quietly leaves that block unformatted instead of reporting it. This tool parses every block separately so you're told exactly where the problem is.

How to format a .vue file

  1. 1. Paste the component
    Paste the entire .vue file, including its template, script and style blocks.
  2. 2. Click format
    The component is validated block by block and then formatted. The parsers load the first time you use the tool.
  3. 3. Fix any reported block
    The message names the block and the line in your file, so you can go straight to the problem.
  4. 4. Copy the component
    Paste the formatted component back into your project.

Example: a Vue 3 component with script setup and SCSS

VUEInput
<template>
<ul class="todos"><li v-for="t in todos" :key="t.id" @click="toggle(t)">{{t.label}}</li></ul>
</template>
<script setup lang="ts">
import {ref} from 'vue'
const todos=ref<{id:number;label:string}[]>([])
function toggle(t:{id:number}){console.log(t.id)}
</script>
<style scoped lang="scss">.todos{li{cursor:pointer}}</style>
VUEFormatted
<template>
  <ul class="todos">
    <li v-for="t in todos" :key="t.id" @click="toggle(t)">{{ t.label }}</li>
  </ul>
</template>
<script setup lang="ts">
import { ref } from "vue";
const todos = ref<{ id: number; label: string }[]>([]);
function toggle(t: { id: number }) {
  console.log(t.id);
}
</script>
<style scoped lang="scss">
.todos {
  li {
    cursor: pointer;
  }
}
</style>

Supported block languages

Languages supported in each block of a Vue single-file component
BlockFormatted and validatedLeft as written
<template>HTML template syntaxlang="pug" templates
<script>JavaScript, lang="ts", lang="tsx", lang="jsx"Other languages
<style>CSS, lang="scss", lang="less"lang="stylus", lang="sass" (indented)
Custom blocksBlocks with lang="json", such as <i18n lang="json">Other custom blocks, such as <docs>

Frequently asked questions

Does it work with Vue 2 and the Options API?

Yes. Formatting is about syntax, not the Vue version, so Options API components with data(), methods and computed format just like Composition API code.

Are errors inside template expressions detected?

Structural template errors, such as a mismatched closing tag, are reported. A broken JavaScript expression inside an attribute like @click is left unformatted rather than reported, so check those in your editor or with eslint-plugin-vue.

Can I format just the template or just the script?

Paste the part you need inside its block, for example only a <template> section. For a plain TypeScript or SCSS snippet without Vue tags, use the TypeScript or SCSS formatter instead.

Does it check Vue-specific rules like missing :key in v-for?

No. That's linting rather than syntax. eslint-plugin-vue checks Vue best practices; this tool makes sure the code parses and is consistently formatted.

Is my component uploaded?

No. All parsing and formatting happens in your browser.

Working on the pieces separately? Use the TypeScript formatter for script code and the SCSS formatter for styles.