gcloud alpha topic formats Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha topic formats - resource formats supplementary help
- DESCRIPTION
(ALPHA)Mostgcloudcommands return a list ofresources on success. By default they are pretty-printed on the standard output.The--format=NAME[ATTRIBUTES](PROJECTION)and--filter=EXPRESSIONflags along withprojections can be used to format and change the default output to a moremeaningful result.Use the
--formatflag to change the default output format of acommand. Resource formats are described in detail below.Use the
--filterflag to select resources to be listed. For detailsrun $gcloud topic filters.Use resource-keys to reach resource items through a unique path of names fromthe root. For details run $gcloud topic resource-keys.
Use projections to list a subset of resource keys in a resource. For details run$gcloud topicprojections.
Note: To refer to a list of fields you can sort, filter, and format by for eachresource, you can run a list command with the format set to
textorjson. For example, $gcloud compute instanceslist --limit=1 --format=text.To work through an interactive tutorial about using the filter and format flagsinstead, see:https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/cloud-shell-tutorials&page=editor&tutorial=cloudsdk/tutorial.md
- Formats
- A format expression is used to change the default output format of a command.Many output formats are available; some for pretty printing human-readableoutput and others for returning machine-readable output.
A format expression has 3 parts:
NAMEnameATTRIBUTES[[no-]attribute-name[=value] [,… ]]PROJECTION(resource-key[, …])
NAMEis required,ATTRIBUTESareoptional, andPROJECTIONSmay be required for someformats. Unknown attribute names are silently ignored.Eachgcloudlistcommand has a default format expression. The--formatflag canalter or replace the default. For example, adds box decorations to a default table, and--format="[box]"
lists the resource in--format=jsonjsonformat.The formats and format specific attributes are:config- A dictionary of dictionaries in config style.
The format attributes are:
export- Display the dictionary as a list of system specific environment export commands.
unset- Display the dictionary as a list of system specific environment unset commands.
csv- Comma Separated Valueswith no keys. This format requires a projection to define the values to beprinted.
To use
\nor\tas an attribute value please escapethe\with your shell's escape sequence, exampleseparator="\\n"for bash.The format attributes are:
delimiter="string"- The string printed between list value items, default ";".
no-heading- Disables the initial key name heading record.
separator="string"- The string printed between values, default ",".
terminator="string"- The string printed after each record, default "\n" (newline).
default- An alias for the
yamlformat. To override usegcloud configset core/default_formatproperty. diff- A unified diff of the first two projection columns.
The format attributes are:
format- The format of the diffed resources. Each resource is converted to this formatand the diff of the converted resources is displayed. The default is'flattened'.
disable- Disables formatted output and does not consume the resources. Equivalent to the
noneformat, but also short-circuits early for commands that returnpageable lists. flattened- A flattened tree. Each output line contains one
key:valuepair.The format attributes are:
no-pad- Don't print space after the separator. The default adjusts the space to alignthe values into the same output column. Use
no-padfor comparingresource outputs. separator=SEPARATOR- Print
SEPARATORbetween thekeyandvalue. The default is ": ".
get- Equivalent to the
value[no-transforms]format. Default transformsare not applied to the displayed values. json- JSON, JavaScript Object Notation.
The format attributes are:
no-undefined- Does not display resource data items with null values.
list- An ordered list of items.
The format attributes are:
always-display-title- Display the title even if there are no records.
compact- Display all items in a record on one line.
multi- Each projection key must have a subformat defined by the :format=FORMAT-STRINGattribute. For example,
`--format="multi(data:format=json, info:format='table[box](a, b, c)')"`
formats the
datafield as JSON and theinfofield as aboxed table.The format attributes are:
separator- Separator string to print between each format. If multiple resources areprovided, the separator is also printed between each resource.
none- Disables formatted output and consumes the resources.
object- Bypasses JSON-serialization and prints the object representation of eachresource.
The format attributes are:
separator- The line printed between resources.
terminator- The line printed after each resource.
table- Aligned left-adjusted columns with optional title, column headings and sorting.This format requires a projection to define the table columns. The defaultcolumn headings are the disambiguated right hand components of the column keysin ANGRY_SNAKE_CASE. For example, the projection keys (first.name, last.name)produce the default column heading ('NAME', 'LAST_NAME').
If
--page-size=Nis specified then outputis grouped into tables with at mostNrows. Headings,alignment and sorting are done per-page. The title, if any, is printed beforethe first table.If screen reader option is True, you may observe flattened list output insteadof a table with columns. Please refer to $gcloud topic accessibilityto turn it off.
The format attributes are:
all-box- Prints a box around the entire table and each cell, including the title if any.
box- Prints a box around the entire table and the title cells if any.
format=FORMAT-STRING- Prints the key data indented by 4 spaces using
FORMAT-STRINGwhich can reference any of the supportedformats. no-heading- Disables the column headings.
margin=N- Right hand side padding when one or more columns are wrapped.
pad=N- Sets the column horizontal pad to
Nspaces. The defaultis 1 for box, 2 otherwise. title=TITLE- Prints a centered
TITLEat the top of the table, withinthe table box ifboxis enabled.
text- An alias for the
flattenedformat. value- CSV with no heading and <TAB> separator instead of <COMMA>. Used toretrieve individual resource values. This format requires a projection to definethe value(s) to be printed.
To use
\nor\tas an attribute value please escapethe\with your shell's escape sequence, exampleseparator="\\n"for bash.The format attributes are:
delimiter="string"- The string printed between list value items, default ";".
quote- "…" quote values that contain delimiter, separator or terminator strings.
separator="string"- The string printed between values, default "\t" (tab).
terminator="string"- The string printed after each record, default "\n" (newline).
yaml- YAML, YAML ain't markup language.
The format attributes are:
null="string"- Display string instead of
nullfor null/None values. no-undefined- Does not display resource data items with null values.
version=VERSION- Prints using the specified YAML version, default 1.2.
All formats have these attributes:
disable- Disables formatted output and does not consume the resources.
json-decode- Decodes string values that are JSON compact encodings of list and dictionaryobjects. This may become the default.
pager- If True, sends output to a pager.
private- Disables log file output. Use this for sensitive resource data that should notbe displayed in log files. Explicit command line IO redirection overrides thisattribute.
transforms- Apply projection transforms to the resource values. The default is formatspecific; table-like formats may define default transforms to certain columns.Use
no-transformsto disable.
- EXAMPLES
- List a table of compute instance resources sorted by
namewith boxdecorations and titleInstances:gcloudcomputeinstanceslist--format="table[box,title=Instances](name:sort=1, zone:label=zone, status)"List a nested table of the quotas of a region:
gcloudcomputeregionsdescribeus-central1--format="table(quotas:format='table(metric,limit,usage)')"Print a flattened list of global quotas in CSV format:
gcloudcomputeproject-infodescribe--flatten="quotas[]"--format="csv(quotas.metric,quotas.limit,quotas.usage)"List the disk interfaces for all compute instances as a compact comma separatedlist:
gcloudcomputeinstanceslist--format="value(disks[].interface.list())"List the URIs for all compute instances:
gcloudcomputeinstanceslist--format="value(uri())"List all compute instances with their creation timestamps displayed according tothe local timezone:
gcloudcomputeinstanceslist--format="table(name,creationTimestamp.date(tz=LOCAL))"List the project authenticated user email address:
gcloudinfo--format="value(config.account)"List resources filtered on repeated fields by projecting subfields on a repeatedmessage:
gcloudalphagenomicsreadgroupsetslist--format="default(readGroups[].name)"Return the scope of the current instance:
gcloudcomputezoneslist--format="value(selfLink.scope())"selfLink is a fully qualified name. (e.g.'https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a')The previous example returns a list of just the names of each zone (e.g.'us-central1-a'). This is because selfLink.scope() grabs the last part of theURL segment. To extract selfLink starting from /projects and return the scope ofthe current instance:
gcloudcomputezoneslist--format="value(selfLink.scope(projects))"List all scopes enabled for a Compute Engine instance and flatten themulti-valued resource:
gcloudcomputeinstanceslist--format="flattened(name,serviceAccounts[].email,serviceAccounts[].scopes[].basename())"Display a multi-valued resource's service account keys with the correspondingservice account, extracting just the first '/' delimited part with segment(0):
gcloudiamservice-accountskeyslist--iam-account=svc-2-123@test-minutia-123.iam.gserviceaccount.com--project=test-minutia-123--format="table(name.scope(serviceAccounts).segment(0):label='service Account',name.scope(keys):label='keyID',validAfterTime)"The last example returns a table with service account names without their fullpaths, keyID and validity.
- NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudtopicformatsgcloudbetatopicformats
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-07 UTC.