What is Syntax?

Definition of Syntax and why proper Syntax is important

Picture of a man writing Haida words on a marker board
© Farah Nosh / Getty Images News / Getty Images

In the computer world, the syntax of a command refers to the rules in which the command can be run in order for a piece of software to understand it.

For example, a command's syntax may dictate case sensitivity and what kinds of options are available that make the command operate in different ways.

Syntax is Like a Language

To better understand computer syntax, think of it as a language, like English, German, Spanish, etc.

A language syntax requires that certain words and punctuation be used in the right way so that someone hearing or reading the words can understand them correctly. If words and characters are placed incorrectly in a sentence, it'll be very difficult to understand.

Much like with language, the structure, or syntax, of a computer command must be coded or executed perfectly in order for it to be understood, with all the words, symbols, and other characters positioned in just the right way.

Why is Syntax Important?

Would you expect someone who reads and speaks only in Russian to understand Japanese? Or what about someone who only understands English, to be able to read words written in Italian?

Similarly, different programs (much like different languages) require different rules that must be followed so that the software (or person, with spoken language) can interpret your requests.

Syntax is an important concept to understand when working with computer commands because an inappropriate use of syntax will mean that a computer can't understand what it is that you're after.

Let's look at the ping command as an example of proper, and improper, syntax. The most common way that the ping command is used is by executing ping, followed by an IP address, like this:


This syntax is 100% correct, and because it's correct, the command-line interpreter, probably Command Prompt in Windows, can understand that I'm wanting to check if my computer can communicate with that specific device on my network.

However, the command will not work if I rearrange the text and put the IP address first, and then the word ping, like this: ping

I'm not using the right syntax, so although the command looks a bit like it should, it will not work at all because my computer has no idea how to handle it.

Computer commands that have the wrong syntax are often said to have a syntax error, and will not run as intended until the syntax is corrected.

Although it's certainly possible with simpler commands (as you saw with ping), you're much more likely to run into a syntax error as computer commands get more and more complex. Just look at these format command examples to see what I mean.

You can see in just this one example with ping that it's very important to be able to not only read syntax correctly, but to of course be able to apply it perfectly.

Proper Syntax with Command Prompt Commands

Every command does something different, so they each have different syntax. Looking through my table of Command Prompt commands is a quick way to see just how many commands there are in Windows, all of which have certain rules that apply to how they can be used.

See How To Read Command Syntax for detailed help deciphering the syntax I use on this site when describing how a particular command can, or can not, be executed.