CSharpier – opinionated C# and XML formatter

CSharpier is an opinionated code formatter for C# and XML that automatically applies a consistent set of formatting rules. Rather than requiring developers to agree on numerous stylistic preferences, it provides a largely predetermined formatting style inspired by Prettier, reducing formatting differences across a codebase.

The formatter parses source files and produces consistently structured output, including indentation, whitespace, line wrapping and expression layout. A small number of configuration options allow teams to control practical requirements such as line width, indentation and line endings. XML formatting also provides controls for handling whitespace-sensitive content, which is important when working with project files and other structured documents.

CSharpier can be used from the command line, integrated into code editors or incorporated into automated development workflows. Its checking mode identifies files that do not conform to the expected formatting without changing them, making it useful for enforcing consistent code formatting across collaborative projects.

This is free and open source software.

Key Features

  • Automatically format C# source code and XML documents.
  • Opinionated formatting rules inspired by Prettier.
  • Consistent indentation, whitespace, line wrapping and expression layout.
  • Configure print width, indentation size, tabs and line endings.
  • Support for JSON and YAML configuration files.
  • Read compatible formatting settings from EditorConfig files.
  • Configuration overrides allow different rules for selected file patterns.
  • Control XML whitespace sensitivity to preserve significant document content.
  • Format individual files or complete directory trees recursively.
  • Read source code from standard input and write formatted output to standard output.
  • Check whether files conform to formatting rules without modifying them.
  • Return a non-zero exit status for formatting violations in automated checks.
  • Validate C# formatting changes by comparing syntax trees before and after formatting.
  • Exclude files and directories using .csharpierignore and .gitignore patterns.
  • Ignore individual statements, members or sections of code using special comments.
  • Automatically exclude common generated source files, with an option to include them.
  • Formatting cache avoids unnecessary processing of unchanged files.
  • Editor integrations for Visual Studio, Visual Studio Code, JetBrains Rider, Neovim, Emacs and Zed.
  • Format code automatically when saving files in supported editors.
  • Integrate formatting checks with pre-commit hooks and continuous integration workflows.
  • API for invoking the formatter programmatically.

Website: github.com/belav/csharpier
Support:
Developer: belav
License: MIT License

CSharpier is written in C#. Learn C# with our recommended free books and free tutorials.


Related Software

C# Code Formatters
UncrustifyHighly configurable source code beautifier supporting many languages
Artistic StyleFlexible source code indenter and formatter for C, C++, C# and Java
CSharpierOpinionated C# formatting with zero configuration
ClangFormatAutomatically formats C, C++, Java and other source code consistently

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted