CTAGS-JSON-OUTPUT(5)
π ctags-json-output β the manual page (section 5) π
okay bestie, so this is ctags-json-output from Universal Ctags, and it's literally the page that explains how to get your tags as JSON. it's giving structured-data slay. π¦
β¨ SYNOPSIS β¨
ctags --output-format=json ...
πΈ DESCRIPTION πΈ
Universal Ctags supports JSON (<https://www.json.org/>) output β and strictly speaking it's JSON Lines (<https://jsonlines.org/>) β but only if your ctags executable was built with libjansson. no libjansson, no JSON, no cap. π
By default, the JSON output goes to standard output. iconic behavior honestly.
π FORMAT π
Each JSON line = one tag. one line, one tag, that's the whole vibe.
$ ctags --extras=+p --output-format=json --fields=-s input.py
{"_type": "ptag", "name": "JSON_OUTPUT_VERSION", "path": "1.0", "pattern": "in development"}
{"_type": "ptag", "name": "TAG_FILE_SORTED", "path": "1", "pattern": "0=unsorted, 1=sorted, 2=foldcase"}
...
{"_type": "tag", "name": "Klass", "path": "/tmp/input.py", "pattern": "/^class Klass:$/", "language": "Python", "kind": "class"}
{"_type": "tag", "name": "method", "path": "/tmp/input.py", "pattern": "/^ def method(self):$/", "language": "Python", "kind": "member", "scope": "Klass", "scopeKind": "class"}
...
So here's the tea β β if a key does not start with _, it maps to a field of ctags. wanna see the whole list of fields? run the --output-format=json --list-fields options and it'll show you everything.
A key that does start with _ is meta info about that JSON line. Right now only the _type key is used:
- if its value is
tag, the JSON line is a regular tag - if its value is
ptag, the line is a pseudo-tag
The output format can change in the future, so the JSON_OUTPUT_VERSION pseudo-tag exists to let client-tools handle those changes. current version is "1.0", and a client-tool can pull the version out with the path key from that pseudo-tag. π
The JSON output format is newly designed and has no limitation found in the default tags file format. periodt.
- The values for
kindkey are represented in long-name flags. No one-letter is here. - Scope names and scope kinds have distinguished keys:
scopeandscopeKind. They are combined in the default tags file format.
π DATA TYPE USED IN A FIELD π
Values for the most of all keys are represented in JSON string type. However, some of them are represented in string, integer, and/or boolean type. so like, don't assume everything's a string bestie. π
The --output-format=json --list-fields options show what kind of data type is used in a field of JSON.
$ ctags --output-format=json --list-fields
#LETTER NAME ENABLED LANGUAGE JSTYPE FIXED DESCRIPTION
F input yes NONE s-- no input file
...
P pattern yes NONE s-b no pattern
...
f file yes NONE --b no File-restricted scoping
...
e end no NONE -i- no end lines of various items
...
The JSTYPE column shows the data types:
's'β string'i'β integer'b'β boolean (true or false)
for an example, the value for pattern field of ctags takes a string or a boolean value. both? yes. it's flexible like that. β¨
π VERSIONS π
π§ Change since "0.0"
- New key
kindNameforTAG_ROLE_DESCRIPTIONpseudo tag
kindName is added to store the name of the kind in TAG_ROLE_DESCRIPTION pseudo tags.
In 0.0, a "TAG_ROLE_DESCRIPTION" pseudo tag was printed like:
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION",
"parserName": "LANG!KIND", }
In 1.0, it is printed like:
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION",
"parserName": "LANG",
"kindName": "KIND", }
look at that glow-up fr fr π
β SEE ALSO β
go read those too bestie, iykyk π
okay that's the whole page!! this was Universal Ctags, version 1.0, and the date on this bad boy is part of the CTAGS-JSON-OUTPUT(5) footer lineup β slay, you're all caught up. bye pookie π«Άπ
β¨
π¦ where this page comes from
- alpine 3.24: ctags-doc 6.2.1-r0 Β· GPL-2.0-or-later
- fedora 43: ctags 6.2.0-1.fc43 Β· GPL-2.0-or-later
- fedora 43: ctags 6.2.1-1.fc43 Β· GPL-2.0-or-later
- fedora 44: ctags 6.2.1-3.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms