ANSI Bold Text - Escape Code 1 for Bold Terminal Output
Make text bold in the terminal using ANSI escape code 1. Examples for Bash, Python, Node.js, Go, and C. Combine bold with colors for emphasized terminal output.
Detailed Explanation
Bold Text with ANSI Code 1
Bold (also called "increased intensity") is the most commonly used ANSI text formatting attribute. It is activated with SGR code 1 and reset with code 22 (or the general reset code 0).
Basic Usage
# Bash
echo -e "\033[1mThis text is bold\033[0m"
# Python
print("\033[1mThis text is bold\033[0m")
# Node.js
console.log("\x1b[1mThis text is bold\x1b[0m");
# Go
fmt.Println("\033[1mThis text is bold\033[0m")
# C
printf("\033[1mThis text is bold\033[0m\n");
Bold + Color
Bold combined with color creates high-impact text:
# Bold red (error messages)
echo -e "\033[1;31mERROR: Something went wrong\033[0m"
# Bold green (success messages)
echo -e "\033[1;32mSUCCESS: Operation completed\033[0m"
# Bold yellow (warnings)
echo -e "\033[1;33mWARNING: Deprecated function\033[0m"
# Bold cyan (info messages)
echo -e "\033[1;36mINFO: Processing started\033[0m"
Bold vs Bright Colors
Historically, some terminals rendered "bold" text by using the bright variant of the current color rather than increasing font weight. This is why codes 1;30 through 1;37 sometimes look identical to codes 90 through 97. Modern terminals typically apply actual bold rendering (increased font weight) in addition to the color.
Resetting Bold Only
To reset bold without affecting other styles, use code 22:
echo -e "\033[1;31mBold red \033[22mnormal red\033[0m"
Code 22 resets both bold (1) and dim (2) to normal intensity, while preserving other attributes like color and underline.
Terminal Compatibility
Bold is universally supported across all terminal emulators. However, the visual rendering depends on the terminal font — some fonts have distinct bold weights while others may simply render bold text in a brighter color.
Use Case
Bold text is used extensively in CLI applications for headings, important messages, command names in help output, error summaries, and status labels. Build tools use bold for the final pass/fail status, package managers use it for package names, and test frameworks use bold for test suite headings. It is the safest formatting attribute for cross-platform tools.