Skip to content

Vue Formatter

Format Vue single file components with this Vue Formatter. Paste a component and the tool formats its script block as JavaScript, or as TypeScript when lang is ts, and its style block as CSS, SCSS or Less according to its lang attribute, indenting both under their tags. The template block is kept on one line with whitespace collapsed. Helpful for Vue developers tidying components for reviews and docs.

Reset

Frequently asked questions

What does the Vue Formatter change in a component?

It formats the content of script and style blocks and places each top level block on its own line. The code inside each block is indented by two spaces under its opening tag.

How is the template block handled?

The template block is kept on a single line, with runs of whitespace collapsed to single spaces. Directives such as v-if, v-for, :prop and @event and mustache expressions are copied exactly as written.

How is the script block formatted?

A plain script block is parsed and printed as JavaScript with two space indentation and semicolons. With lang="ts" it is formatted as TypeScript, which also accepts type annotations.

How is the style block formatted?

A style block is formatted as CSS by default, with one declaration per line. With lang="scss" or lang="less" it uses the SCSS or Less rules, and the scoped attribute is kept.

What happens with a syntax error in the script?

JavaScript and CSS blocks are parsed, so a syntax error stops the tool and its message is shown. Fix the reported problem and format again.

Does it support script setup?

Yes, the setup attribute is kept on the tag and the content is formatted like any other script block. Compiler macros such as defineProps are ordinary function calls to the formatter.

Can I change the indentation?

No, the formatter always uses two spaces and has no options. The same component always produces the same output.

Are comments preserved?

Yes, HTML comments between blocks and comments inside script and style blocks are kept. Comments inside the template stay in place on its single line.

Why is the result fenced as html?

Single file components are read as HTML, so the result is returned as a Markdown code block marked html. Copy the lines between the fences into your .vue file.

How large can the component be?

Up to 5 MB per run; larger input is rejected with a message. The output is identical to the Vue option of the Code Formatter.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.