FormatterHQ

ActionScript Formatter

Format ActionScript 3 packages and classes: braces, indentation and spacing are normalized, and modifiers like public static stay on one line.

Input JAVASCRIPT
Output JAVASCRIPT
Ready.

How to use the ActionScript Formatter

  1. Paste your ActionScript code (.as) into the Input editor, or use Sample, Upload file or Load URL.
  2. Choose the Indent (4 spaces by default, as in Flash and Flex projects).
  3. Press Format to beautify the code.
  4. Use Copy or Download above the output panel to take the formatted ActionScript with you.

An ActionScript formatter for AS3 projects

ActionScript 3 lives on in Apache Flex and Adobe AIR applications, Haxe ports and plenty of legacy code that still needs maintenance. This ActionScript formatter uses js-beautify, which suits AS3 well because the language is a close relative of ECMAScript, plus a fix-up step that keeps AS3 modifiers such as public, private, static and override on the same line as the declaration they belong to.

Example

package com.example{import flash.events.MouseEvent;public class Button extends Sprite{private var _label:String;public function Button(label:String){_label=label;addEventListener(MouseEvent.CLICK,onClick);}private function onClick(e:MouseEvent):void{trace("clicked "+_label);}}}
package com.example {
    import flash.events.MouseEvent;
    public class Button extends Sprite {
        private var _label: String;
        public function Button(label: String) {
            _label = label;
            addEventListener(MouseEvent.CLICK, onClick);
        }
        private function onClick(e: MouseEvent): void {
            trace("clicked " + _label);
        }
    }
}

The package, class and method bodies are indented, each statement is on its own line, and operators are spaced. Because the underlying beautifier treats type annotations like object-literal colons, it prints them as label: String. Adobe's own examples usually write label:String without a space; both compile the same. If you want the compact form, a find-and-replace of : before type names restores it.

What the formatter handles

  • package blocks, import statements and class / interface declarations with extends and implements.
  • Access and other modifiers (public, protected, internal, static, override, final, dynamic) kept together with function, var and const.
  • Getters and setters (public function get label(): String).
  • Metadata tags like [Bindable] written on their own line, and event listener code.

Known limitation: Vector types

The typed-array syntax Vector.<int> is unique to ActionScript. A plain JavaScript beautifier would read its angle brackets as comparison operators and print Vector. < int >, which does not compile. This formatter recognises Vector types, including nested ones such as Vector.<Vector.<String>>, and keeps them exactly as written while it re-indents the code around them.

AS3 conventions the formatter leaves to you

Formatting only changes whitespace and line breaks, so a few ActionScript 3 rules still need a manual check after you tidy a file:

  • One public class per file. The compiler expects the public class or interface in a .as file to have the same name as the file, so Button.as must declare public class Button.
  • Package path matches the folder. package com.example.ui belongs in com/example/ui/ under a source path, otherwise imports fail.
  • Naming. Classes use UpperCamelCase, methods and variables lowerCamelCase, and constants such as static const MAX_ITEMS are upper case. A leading underscore for private backing fields of getters and setters is a common Flex habit.

Keeping these consistent makes legacy Flex or AIR code far easier to review once the layout itself is clean.

Tips

AS3 code usually uses 4-space indentation and braces on the same line, which is the default here. The formatter does not check that code compiles, so an unbalanced brace shows up as indentation drifting to the right. MXML files are XML and can be formatted with the XML Formatter. For JavaScript that has been ported from AS3, the JavaScript Formatter offers more brace-style options. Your code is processed only in your browser.

Frequently asked questions

Why is there a space after the colon in type annotations?
The formatter is based on a JavaScript beautifier, which prints colons with a following space. The code compiles the same; remove the space with find-and-replace if your project prefers name:Type.
Does it support ActionScript 2?
AS2 syntax is similar enough that most code formats correctly, but the tool is tuned for AS3 packages and classes.
Can I format MXML files here?
No. MXML is XML with embedded script blocks. Use the XML Formatter for the markup and paste script blocks here separately.
Will it change my code’s behavior?
No. Only whitespace and line breaks change. ActionScript-specific syntax such as Vector.<int> type parameters and modifier keywords like public static function is preserved.

Last updated September 26, 2026

Related tools