Input

Output

What is PowerShell?

PowerShell is a cross-platform task automation and configuration management framework from Microsoft. It includes a command-line shell and scripting language built on .NET, widely used for Windows administration and DevOps automation. You can learn more on Wikipedia, and the community-maintained PowerShell source is on GitHub.

The PowerShell Formatter normalizes indentation (4 spaces per level), fixes brace alignment for function/if/foreach/try blocks, and removes trailing whitespace. You can find thousands of community modules and scripts on the PowerShell Gallery.

How to Use

1

Paste your PowerShell script

Paste raw or messy PowerShell script into the left editor, or click Upload to load a file.

2

Instant formatting

The formatter automatically normalizes indentation with 4 spaces per level and fixes brace alignment.

3

Copy or download

Use the Copy button to copy the result, or Download to save it as a .ps1 file.

Formatting Example

Example: Format a user creation script

Unformatted input:

$users=@("Alice","Bob","Charlie")
foreach($user in $users){
New-LocalUser -Name $user -NoPassword
Add-LocalGroupMember -Group "Users" -Member $user
Write-Host "Created: $user"
}

Formatted output:

$users = @("Alice", "Bob", "Charlie")
foreach ($user in $users) {
    New-LocalUser -Name $user -NoPassword
    Add-LocalGroupMember -Group "Users" -Member $user
    Write-Host "Created: $user"
}

Frequently Asked Questions

Is PowerShell cross-platform?

Yes. PowerShell Core (v6+) runs on Windows, macOS, and Linux. Windows PowerShell (v5.1) runs only on Windows.

What indentation does PowerShell use?

While no official standard exists, 4 spaces is a widely used convention in PowerShell scripts. Microsoft's PowerShell development guidelines cover best practices for script style.

Can I format .psm1 module files?

Yes. PowerShell module files (.psm1) and script files (.ps1) use the same syntax and are both supported. Published modules are available on the PowerShell Gallery.

Is my PowerShell code safe when I use this tool?

Yes, completely. All formatting happens locally in your browser — your script is never sent to any server. Your PowerShell code stays private and secure at all times.

Related Tools