echo - Display Text
What is the echo command?
The echo command displays text in Command Prompt and batch files. It also turns the display of the commands themselves (the “echo”) on or off.
- Display text:
echo Hello - Control command display:
echo off/echo on - Combined with redirection, it can also create empty files or write text to files
This page explains the basics of echo, the meaning of @echo off, and how to handle special characters, with sample code.
echo command syntax
echo [<message>]
echo [on | off]
| Syntax | Behavior |
|---|---|
echo <text> | Displays the specified text |
echo on | Turns command display on (default) |
echo off | Turns command display off |
echo | Shows the current echo state (such as ECHO is on.) |
@<command> | A leading @ hides the command itself on that line |
Basic usage
In Command Prompt
When you run this command, the text “Hello, World!” that follows echo is displayed.

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
In a batch file
@echo off
setlocal
echo Hello, World!
endlocal
exit
When you run this batch file, Hello, World! is displayed just as in Command Prompt.
What “@echo off” means
echo on and echo off switch whether the command itself is shown on screen when it runs.
echo on(default): both the command and its result are displayedecho off: only the result is displayed
If you run a batch file as is, every command is printed line by line, which makes the output hard to read. That is why batch files usually start with @echo off.
The leading @ means “do not display the command on this line.” Without it, the echo off line itself would still be printed, so the @ is added only to the first line.
@echo off
echo Only the result of this line is displayed
Instead of writing @echo off, you can put @ at the start of just the lines you want to hide. Example: @del temp.txt
Displaying a blank line
Use echo. (a period right after echo) to display a blank line.
Running echo alone shows the echo state, such as ECHO is on. (or ECHO is off. after echo off), instead of a blank line.
In a batch file, echo %UNDEFINED_VAR% with an undefined variable expands to nothing and gives the same result.
When you only want a blank line, echo. is the safe choice.
In Command Prompt
In a batch file
@echo off
setlocal
echo Hello, World!
echo.
echo This is a new line.
endlocal
exit
Advanced usage
Displaying environment variables
To display an environment variable or a variable’s value, use the %variable name% format.
In Command Prompt
This displays the name of the signed-in user.
In a batch file
@echo off
setlocal
echo Your username is %USERNAME%.
endlocal
exit
When you run this batch file, your username is displayed.
Displaying calculation results
You can calculate with set /a and display the result with echo.
In Command Prompt
In Command Prompt, set /a prints the result, 7, directly.
In a batch file
@echo off
setlocal
set /a result=3+4
echo The result is %result%.
endlocal
exit
When you run this batch file, The result is 7. is displayed.
Displaying special characters
The characters &, |, <, > and ^ have special meanings in Command Prompt, so passing them to echo as is does not display them. To display them, put ^ in front of the character. In a batch file, write % as %%.
@echo off
echo A ^& B
echo 50%%
echo 1 ^> 0
This displays A & B, 50% and 1 > 0.
echo Hello > memo.txt sends the output to a file instead of the screen. You can use this to create text files with echo. See the related articles for details.
Summary
echo <text>displays text- Start batch files with
@echo offto hide the commands themselves - Use
echo.for a blank line (a bareechoshows the echo state) - Escape special characters such as
&and>with^