The DISPLAYBARCODE field code in Microsoft Word is a powerful built-in feature that lets you generate various 1D and 2D barcodes—including QR codes—directly inside your document without needing any third-party add-ins.
Basic Syntax
To use DISPLAYBARCODE, you must insert it inside Word field brackets:
- Press
Ctrl + F9(orFn + Ctrl + F9on laptops) to insert curly braces:{ }(do not type them manually). - Inside the braces, enter the formula in this structure:
$$\text{\{ DISPLAYBARCODE “Data” BarcodeType [Flags] \}}$$

Example for a QR Code:
Plaintext
{ DISPLAYBARCODE "https://onetimeschool.com" QR \q 3 \s 150 }
- Press
Shift + F9(or right-click and select Toggle Field Codes) to display the generated barcode image.
Example
Type
Displaybarcode”
Your Text”qr
All Select
Ctrl + F9
Mouse Right button click Toggle Field Codes
Common Field Switches (Flags)
You can customize the appearance and behavior using optional switches at the end of the formula:
| Switch | Function | Example / Values |
\q [0-3] | Error Correction Level (QR code quality) | \q 0 (7%), \q 1 (15%), \q 2 (25%), \q 3 (30% – best for low-quality prints) |
\s [number] | Scaling / Size (percentage scaling factor) | \s 100 (default size), \s 200 (double size) |
\b [RRGGBB] | Foreground Color (Hex code) | \b 0000FF (Blue) |
\c [RRGGBB] | Background Color (Hex code) | \c FFFF00 (Yellow) |
\t | Transparent Background | Simply add \t to remove the background fill |
\h [twips] | Height (mainly for 1D barcodes) | \h 1200 |
Supported Barcode Types
Besides QR, Microsoft Word supports several other popular barcode formats:
QR: Quick Response Code (2D)CODE128: High-density 1D barcode used widely in logisticsCODE39: Standard alphanumeric 1D barcodeUPCA: Universal Product Code (standard retail 12-digit format)EAN13: International 13-digit retail barcodePDF417: Stacked 2D barcode (commonly used on ID cards and shipping labels)
Practical Examples
1. High-Quality Web Link QR Code
Plaintext
{ DISPLAYBARCODE "https://github.com" QR \q 3 \s 120 }
2. Custom Colored QR Code
Plaintext
{ DISPLAYBARCODE "Contact Sales: 555-0199" QR \b 0050A0 \s 150 }
3. Retail Product Barcode (UPC-A)
Plaintext
{ DISPLAYBARCODE "012345678905" UPCA \h 1000 }
Tips & Troubleshooting
- Dynamic Barcodes using Mail Merge: You can combine
DISPLAYBARCODEwith Mail Merge tags to generate unique QR codes or barcodes automatically for bulk documents:Plaintext{ DISPLAYBARCODE { MERGEFIELD WebsiteURL } QR \q 3 } - Barcode Not Updating? If you change the text inside the quotes, press
F9while highlighting the field code to refresh the rendered image. - Cannot See the Result? Ensure you pressed
Ctrl + F9to create the field braces. Typing standard braces{ }using keyboard keys will not work.