C# comment remover

Remove comments from
C# code.

Remove comments from C# source files online. Handles XML doc comments, attributes, LINQ syntax, and string literals correctly.

Free, no signup Runs in your browser Instant, no upload Works on .cs files

Before and after

Real-world C# code on the left. The same code with every comment removed on the right.

c#-input.cs
using System;
using System.Collections.Generic;

namespace Acme.Orders
{
    /// <summary>
    /// Repository for the Orders table.
    /// </summary>
    public class OrderRepository
    {
        // Connection string lives in config
        private readonly string _conn;

        /* Constructor */
        public OrderRepository(string conn)
        {
            _conn = conn; // store for later
        }

        /// <summary>Find by id.</summary>
        public Order? FindById(Guid id)
        {
            var sql = $"SELECT * FROM orders WHERE id = '{id}'"; // bind safely
            return Execute(sql);
        }
    }
}
c#-output.cscleaned
using System;
using System.Collections.Generic;

namespace Acme.Orders
{
    public class OrderRepository
    {
        private readonly string _conn;

        public OrderRepository(string conn)
        {
            _conn = conn;
        }

        public Order? FindById(Guid id)
        {
            var sql = $"SELECT * FROM orders WHERE id = '{id}'";
            return Execute(sql);
        }
    }
}
Why use it

Built for C# specifically.

C# files often carry XML doc comments above every public member, plus inline notes accumulated over many releases. When sharing a snippet, generating clean training material, or comparing two solutions side-by-side, removing them up front is faster than scrolling past them. Uncommenter strips all comment styles while leaving attributes, generics, and string interpolation untouched.

  • // line and /* */ block comments removed
  • /// XML documentation comments removed
  • Attributes ([Serializable], etc.) preserved
  • String interpolation ($"...") and verbatim strings (@"...") kept intact
  • Auto-detected from .cs files
How it works

Strip comments in 30 seconds.

  1. 1

    Open the tool

    Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.

  2. 2

    Paste your C# code

    Drop your .cs file in, or paste code into the editor. Auto-detection picks up C# from the extension or file content.

  3. 3

    Click 'Remove Comments'

    The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.

  4. 4

    Copy or download

    Grab the cleaned output. Your code never left your browser.

FAQ

C# questions, answered.

Does it strip XML doc comments?

+

Yes. /// triple-slash documentation lines are treated as line comments and removed by default. Attributes like [Serializable] are language syntax and stay.

Are verbatim strings handled?

+

Yes. @"a verbatim // string" is parsed as a verbatim string literal, so the // inside is preserved.

What about Razor (.cshtml) files?

+

Razor uses a different syntax with @* *@ comments that we don't currently target. The C# landing page covers .cs files only.

Other languages

Working in something else?

Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.

Try it on your C# code now.

Free forever. No signup. No upload. Runs entirely in your browser.

Open uncommenter