Skip to main content

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

FlagDefaultDescription
--fields=FIELDSname,value,typeComma-separated list of columns to display
--format=FORMATtableOutput format: table, json, csv, yaml, count
--strictReturn only definitions actually set in the file
--config-file=PATHRead 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

  1. Run after every config change (wp config set, wp config create) to confirm the result.
  2. Export to CSV for documentation — useful for audits or client handoffs.
  3. Use --format=json in automation to process values programmatically.
  4. Combine with grep to quickly check if a constant is defined.

Troubleshooting

ProblemCauseFix
Error: No wp-config.php foundRun from wrong directorycd /var/www/html or use --path
Salts and secrets visibleOlder WP-CLI versionsUpdate WP-CLI; newer versions mask sensitive data
Missing expected constantNot defined in configUse 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