To get the default Google Cloud Platform (GCP) project ID using the Cloud SDK Command Line Interface (CLI) in a one-liner, use this command: gcloud config list –format ‘value(core.project)’ 2>/dev/null
This command lists the gcloud configuration properties and filters the output to display only the project ID.
- The –format ‘value(core.project)’ flag specifies that you want to extract the value of the core.project property.
- The 2>/dev/null part suppresses any error messages to keep the output clean.
You can also use this command.
gcloud config get-value project
This command will return the project ID currently set as the default in your gcloud configuration. If no default project is set, the command will return an empty value.
That’s it.

Amit Doshi is a Cloud Engineer who has experienced more than 5 years in AWS, Azure, and Google Cloud. He is an IT professional responsible for designing, implementing, managing, and maintaining cloud computing infrastructure, applications, and services.