wp config list
Overview
Display all constants and variables from wp-config.php in one command. Use it to audit configuration, debug environment issues, or compare values across servers.
What It Does
wp config list reads wp-config.php and outputs all defined constants and variables in a structured format. By default it shows a table with name, value, and type columns.
Syntax
wp config list [--fields=<fields>] [--format=<format>] [--strict] [--config-file=<path>]
Options & Flags
| Flag | Default | Description |
|---|---|---|
--fields=FIELDS | name,value,type | Comma-separated list of columns to display |
--format=FORMAT | table | Output format: table, json, csv, yaml, count |
--strict | — | Return only definitions actually set in the file |
--config-file=PATH | — | Read from a file at a custom path |
Basic Usage
Default table output
wp config list
Output:
+--------------------+-----------------------------+----------+
| name | value | type |
+--------------------+-----------------------------+----------+
| table_prefix | wp_ | variable |
| DB_NAME | wpdb | constant |
| DB_USER | wpuser | constant |
| DB_PASSWORD | ******** | constant |
| DB_HOST | localhost | constant |
| WP_DEBUG | false | constant |
+--------------------+-----------------------------+----------+
Passwords are masked
Sensitive values like DB_PASSWORD and authentication salts are automatically masked in the output.
JSON output
wp config list --format=json
CSV output (for spreadsheet import)
wp config list --format=csv > wp-config-audit.csv
YAML output
wp config list --format=yaml
Show only names
wp config list --fields=name
Count total entries
wp config list --format=count
Real-World Scenarios
Scenario 1: Pre-deployment config audit
echo "=== Config Audit: $(date) ===" >> audit.log
wp config list --format=csv >> audit.log
Scenario 2: Compare configs between environments
# On staging
wp config list --format=json > staging-config.json
# On production (run separately)
wp config list --format=json > prod-config.json
diff staging-config.json prod-config.json
Scenario 3: Verify a specific constant exists
wp config list | grep WP_CACHE
Scenario 4: Check all database connection values
wp config list --fields=name,value | grep -E "^DB_"
Best Practices
- Run after every config change (
wp config set,wp config create) to confirm the result. - Export to CSV for documentation — useful for audits or client handoffs.
- Use
--format=jsonin automation to process values programmatically. - Combine with
grepto quickly check if a constant is defined.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
Error: No wp-config.php found | Run from wrong directory | cd /var/www/html or use --path |
| Salts and secrets visible | Older WP-CLI versions | Update WP-CLI; newer versions mask sensitive data |
| Missing expected constant | Not defined in config | Use wp config set to add it |
Quick Reference
wp config list # Table view of all config
wp config list --format=json # JSON output
wp config list --format=csv # CSV export
wp config list --fields=name,value # Name and value only
wp config list --format=count # Count total entries
Next Steps
wp config get— get the value of a single constant.wp config set— add or update a constant.wp config delete— remove a constant.wp config shuffle-salts— rotate authentication keys.