DotNetFormatter is a handy tool that automatically formats C# code on LeetCode and AlgoExpert pages. Behind the scenes, it works by integrating a user script (via Tampermonkey) with a local .NET API. Once set up, the formatter hooks into LeetCode’s and AlgoExpert's editors and gives you quick access to beautifully formatted C# code.
- Install Tampermonkey extension for Google Chrome
- Install user script
- Install .Net Runtime (If it isn't installed already)
- Download DotNetFormatter.exe (make sure port 5000 is available)
- Run DotNetFormatter.exe. It functions as an API and runs at http://localhost:5000
Visiting this link will display a Swagger page
-
Open LeetCode or AlgoExpert problem page, e.g.: https://leetcode.com/problems/generate-parentheses/
-
Press ALT + SHIFT + F to format the C# code