Format Code Now
/
Web & markupActionScript Beautifier Next: CSS Beautifier and Minifier ›

ActionScript Beautifier and Minifier

WM-71

Paste ActionScript 3 to re-indent it by its braces, or strip comments and extra spaces to shrink it. Beautify only changes indentation; it never moves code between lines.

Runs in your browser. Nothing is uploaded.

ActionScript

Result

How to use it

  1. Paste your ActionScript into the input box, or open a .as file or drop it on the box.
  2. Pick 2, 3, 4 or 8 spaces, or a tab, for the indent.
  3. Choose Beautify to re-indent, or Minify to remove comments and extra whitespace.
  4. Copy the result or download it as a .as file.

What Beautify does and does not do

Beautify changes the leading whitespace of each line and nothing else. Each line is indented by how many braces, parentheses and brackets are open at that point. Inside a switch, case labels sit one level in and their statements one level deeper. Stars in block comments are lined up. It does not break long lines, join short ones, add semicolons or move braces, so a minified file pasted in stays on one line. For that case you need a full parser, which no browser library offers for ActionScript.

How Minify works

Minify removes comments and collapses spaces around operators and punctuation. Strings and regular expression literals are copied as written. A line break is kept wherever removing it could change the meaning, for example between two statements that have no semicolon, so the result is often a few lines rather than one. Comments that start with /*! can be kept with the checkbox. Nothing is renamed or shortened, so the saving comes from whitespace and comments only.

Limits you should know about

The tool checks only that brackets match and that comments are closed. It does not compile the code or check types. E4X XML literals are treated as plain text, so a line inside a multi-line XML literal gets the indent of the surrounding code. A regular expression right after a closing parenthesis can be read as division, which is rare in real code.

Error messages and what to do

MessageWhat it meansFix
Unmatched closing brace "}" at line 1A } closes a block that was never opened.Remove the extra } or add the missing opening brace above it.
Unclosed brace "{" at the end of the code. Add the matching closerA { is never closed before the text ends.Add the missing } at the end, or find the block that lost its closer.
Unclosed comment starting at line 1. Add the closing */A /* comment has no */ after it.Add */ where the comment should end.

Questions people ask

How do I format ActionScript code online?

Paste the code into the input box and click Beautify. Each line is re-indented from its brace and parenthesis nesting, using the indent you pick. The tool changes leading spaces only, so your line breaks and semicolons stay as you wrote them. Copy the result when it looks right.

Does it work with ActionScript 2 as well as 3?

It re-indents by brackets, so it handles any ActionScript that uses braces, which includes AS2 and AS3. It does not parse the language, so it does not care about types or class syntax. Packages, classes, functions and switch blocks are indented the same way in both.

Can it minify ActionScript?

Yes. Minify removes comments and extra whitespace and keeps strings and regular expressions as written. It keeps a line break where removing it could change the meaning, so output is not always a single line. It does not rename variables, so the file shrinks less than with a compiler.

Why did my long line not wrap?

Beautify only re-indents and never moves code between lines. That is deliberate: without a full ActionScript parser, wrapping lines risks changing the code. If you need lines split, add the line breaks yourself and run Beautify again to indent them.

Does it keep my comments when beautifying?

Yes. Line comments and block comments are kept. Lines inside a block comment that start with a star are lined up under the opening /*, and other comment text is left exactly as you wrote it. Only Minify removes comments.

What happens to code inside strings?

Strings are left exactly as written, including any braces or comment markers inside them. A quote that has no partner on the same line is treated as ordinary text rather than a string, which keeps apostrophes in XML literals from breaking the indent.

About this tool

There is no ActionScript formatting library to build on, so this is our own code and it is deliberately modest. Beautify only re-indents: it changes the leading spaces of each line from the nesting of braces, parentheses and brackets, puts case labels one level in and their bodies one more, and aligns the stars in block comments. It never splits or joins lines, adds or removes semicolons, or moves braces, so code written as one long line stays one long line. Minify removes comments and extra spaces and keeps a line break where removing it could change the meaning, such as between statements that have no semicolon, so the result is not always a single line. Strings and regular expression literals are left alone. E4X XML literals are treated as ordinary text. Nothing is renamed or compiled, and the code is not checked beyond matching brackets and closed comments.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.