When I say "comment out", does it mean to uncomment something or comment it?
What is better, or more correctly used?

PS: I'm talking about source code.


To comment out is to render a block of code inert by turning it into a comment.

In C# code for example, commenting out code is done by putting // at the start of a line, or surrounding the code with /* and */. Here the line inside the loop is commented out:

for (int i = 0; i < 10; i++) {

To uncomment something means to remove the characters that makes it a comment. The expression only makes sense if the comment contains something that would work as code, usually something that was commented out earlier. To uncomment a regular comment would just cause a syntax error.


"Comment out" means to use comment syntax to remove something from the parsed code. "Uncomment" is the reverse operation. They are both the correct expression for their respective referents.

  • 5
    @Genesis: To clarify, as I understand it, to comment out means to leave the unwanted code unchanged, but insert before it (and after, for multi-line comments) the relevant character sequence that makes the compiler ignore that code when compiling. In C++ that's a double-slash before it on a single-line, or slash/asterisk before and asterisk/slash after where multiple lines are being commented out. – FumbleFingers Jul 9 '11 at 12:37
  • 2
    I don't understand what that means. Are you just saying that as an alternative to enclosing the entire unwanted section in "begin/end comment" delimiters, you can prefix each line with the sequence that means "the rest of this line is a comment". The important point is that the unwanted code itself remains unchanged - it's just that the compiler/interpreter is directed to ignore it. – FumbleFingers Jul 9 '11 at 13:36
  • 2
    I never mentioned "the line" anywhere when referring to what was to be commented out. I called it "the unwanted code", which could be anything from part of a line to a substantial section of code. – FumbleFingers Jul 9 '11 at 14:10
  • 1
    No worries. I think yours is the best answer anyway, but when OP paraphrased it back as "remove out this line" I thought he might not have understood the answer fully. So it seemed important to clarify that the actual text of the code being "commented out" remains unchanged - you just mark it so it's ignored. – FumbleFingers Jul 10 '11 at 16:19
  • 3
    Not sure anyone has explicitly said this yet, it may help the OP to internalise things... The way I've always understood it is that the "out" and "in" relate to the compilation. You are adding/removing code from the build. "Commenting out" is taking a piece of code out of the build. – Rupe Jul 15 '14 at 10:13

As reported by the NOAD, the meaning of comment out is (computing) turn part of a program into a comment so that the computer ignores it when running the program.

You could try commenting out that line.

The definition provided by Dictionary.com is the following one:

To surround a section of code with comment delimiters or to prefix every line in the section with a comment marker. This prevents it from being compiled or interpreted.

The PC Magazine Enciclopedia defines comment out using the following words:

To disable lines of code in a program by surrounding them with comment-start and comment-stop characters.

Answers.com defines comment out as (computer science) To render a statement in a computer program inactive by making it a comment.

Comment out doesn't mean removing a comment.

  • I think your edit actually made the last sentence less accurate... it's not really "adding a comment" (which is about inserting new explanatory material) but "adding a comment marker" or "converting active code into a comment". – Hellion Aug 30 '19 at 13:34
  • The previous revision said to add a comment to a code line. The meaning didn't change. – kiamlaluno Aug 30 '19 at 14:41

For me when you comment it is to clarify something that will make it easier for the user to understand like in c++(although a simple example and should not be used like this):

int n = 0;
//add 4 to variable n and then output it
n += 4;
cout << n;

But shall someone say comment out I think of the coder commenting out a line or section of code to see what happens with program execution. Such as this:

First code:

int n = 0;
n += 4;
cout << n;

And then commenting out a line to see what will happen with the program:

int n = 0;
//n += 4;
cout << n;

The first code will output 4 but when I comment out the second line it will output 0 I simply use this so that I don't have to delete code and then rewrite it because twe


The idea is "remove by commenting/turning into a comment". Note that "out" is used to mean remove in a number of phrasal verbs: "dig out", "force out", "smoke out" etc-- and indeed, on more or less the same analogy "wipe out".

As the opposite, you can "uncomment" a line/section, or you "comment it back in". The latter is slightly odd, because logically you are uncommenting so that the code to be put back in. But hey, language doesn't always use the same logic as mathematics.

//That is a function for calculating 2 intgers and display the result. - this is a comment
int add(int a, int b)
    return a+b;

Now, you think the "print(a+b)" is useless, you don't want it anymore, but you want to remain it at here in case whenever you want to reuse it. You don't have to delete this line, you can just comment out it like that,

int add(int a, int b)
    return a+b;

Not the answer you're looking for? Browse other questions tagged or ask your own question.