XAML Code Prettifier & Indenter
Paste minified or messy XAML markup, instantly format with proper indentation and attribute highlighting
XML (Extensible Markup Language) is a markup language designed to store and transport data. Unlike HTML, XML tags are not predefined — you define your own tags to describe the data structure. XML is widely used in web services (SOAP), configuration files, document formats (DOCX, SVG), and data interchange between different systems.
Paste messy or minified WPF, UWP, or .NET MAUI markup and get clean, indented XAML back instantly. Pick 2-space or 4-space indentation, hit Format, and the nesting structure becomes readable again — or switch to Minify when you need everything on one line.
Attributes, binding expressions, and xmlns declarations stay exactly as you wrote them. Only whitespace changes. And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter tokenizes your XAML into opening tags, closing tags, self-closing elements, comments, and CDATA blocks. It walks through each token, tracking nesting depth with a stack. Every opening tag increases the indent level; every closing tag decreases it. Self-closing tags stay at the current level. Attributes and namespaces are preserved exactly — only whitespace changes.
Examples
Minified WPF Button
Someone exported a Window and everything collapsed to one line.
<Button Content="Save" Width="120" Height="36" Margin="10" Click="OnSave"/>
<Button
Content="Save"
Width="120"
Height="36"
Margin="10"
Click="OnSave" />
Nested Grid with StackPanel
A typical layout where three levels of nesting got flattened during a merge conflict resolution.
<Grid><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/></Grid.RowDefinitions><StackPanel Grid.Row="0"><TextBlock Text="Header"/></StackPanel><ListView Grid.Row="1" ItemsSource="{Binding Items}"/></Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBlock Text="Header" />
</StackPanel>
<ListView
Grid.Row="1"
ItemsSource="{Binding Items}" />
</Grid>
MAUI ContentPage with Data Binding
Grabbed from a .NET MAUI tutorial — the xmlns declarations and binding expressions need to stay intact while the structure gets readable indentation.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.MainPage"><VerticalStackLayout><Label Text="{Binding UserName}" FontSize="24"/><Entry Placeholder="Enter name" Text="{Binding UserName, Mode=TwoWay}"/><Button Text="Submit" Command="{Binding SubmitCommand}"/></VerticalStackLayout></ContentPage>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.MainPage">
<VerticalStackLayout>
<Label
Text="{Binding UserName}"
FontSize="24" />
<Entry
Placeholder="Enter name"
Text="{Binding UserName, Mode=TwoWay}" />
<Button
Text="Submit"
Command="{Binding SubmitCommand}" />
</VerticalStackLayout>
</ContentPage>
Who Uses This
Cleaning up auto-generated XAML from Visual Studio designers before committing to source control.
Reformatting cross-platform UI markup after copying snippets from docs or Stack Overflow.
Making XAML samples readable for students who are still learning the tag hierarchy.
Quickly prettifying a diff to check whether a PR changes structure or just reshuffles attributes.
Common Mistakes
If a closing tag is missing or an angle bracket is unescaped, the formatter can't build the tree. Fix the broken tag first, then format. The error message will usually point to the exact line.
This tool only fixes indentation and line breaks. It won't alphabetize your attributes or move xmlns declarations to the top. That's by design — reordering attributes can break tooling that depends on attribute order.
If you accidentally paste your .xaml.cs content mixed with the XAML markup, the parser will choke on the C# syntax. Make sure you're only pasting the .xaml file content.
Technical Details
- Processing: 100% client-side JavaScript — nothing leaves your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Indent Options: 2-space or 4-space indentation
- Supported Dialects: WPF, UWP, Xamarin.Forms, .NET MAUI, Silverlight
- Max Size: Limited only by browser memory — tested with 10,000+ line files
Frequently Asked Questions
What is a XAML formatter?
A XAML formatter takes messy or minified XAML markup and adds proper indentation and line breaks so you can actually read it. Think of it like a code beautifier, but specifically built for the XML-based UI language used in WPF, UWP, and .NET MAUI apps.
Does this work with WPF and .NET MAUI XAML?
Yes. It handles any well-formed XAML regardless of the framework. WPF, UWP, Xamarin.Forms, .NET MAUI, even Silverlight if you still have that lying around. The formatter treats XAML as structured XML, so framework-specific tags don't matter.
Will formatting change my binding expressions?
No. Binding expressions like {Binding Path=Name, Mode=TwoWay} and markup extensions stay exactly as you wrote them. The formatter only touches whitespace outside of attribute values. Your bindings, converters, and static resources won't be modified.
How do I minify XAML?
Paste your XAML and click the Minify button instead of Format. It strips all unnecessary whitespace and puts everything on one line. Useful for embedding XAML strings in code or reducing file size in resource dictionaries.
Is my XAML code safe when I paste it here?
Completely. Everything runs in your browser with JavaScript — no server involved. Your XAML is never transmitted anywhere. You can disconnect from the internet and the tool keeps working. Check your browser's network tab if you want proof.