ctags-json-output(5)
π NAME π
ctags-json-output β the JSON based ctags output, bestie!! this is page 5 of the Universal Ctags manual and it's literally the glow-up era of tag output π¦
β¨ SYNOPSIS β¨
ctags --output-format=json ...
πΈ DESCRIPTION πΈ
okay so. Universal Ctags supports JSON output β and when I say JSON I mean <https://www.json.org/>, and strictly speaking it's actually JSON Lines <https://jsonlines.org/> (iykyk, one object per line, no giant array, chef's kiss π ).
β οΈ the catch: this only works if thectagsexecutable was built withlibjansson. no jansson, no JSON, periodt.
and where does it go? standard output, by default. no cap. π
π FORMAT π
every single JSON line = one tag. that's the whole vibe. one line, one tag, slay.
$ 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 key situation, and it's giving very much "read the first character" energy:
- a key that does not start with
_maps to a field of ctags. wanna see the whole field list? run the--output-format=json --list-fieldsoptions, they will literally list the fields for you. π«Ά - a key that does start with
_is meta information about that JSON line. right now only the_typekey is used. if its value istag, the line is a regular tag. if the value isptag, the line is a pseudo-tag. iconic.
π real talk: the output format can change in the future. that's not me being dramatic, that's the actual deal. theJSON_OUTPUT_VERSIONpseudo-tag exists so client-tools get a heads up about those changes. current version is"1.0". a client-tool can extract the version with thepathkey from that pseudo-tag. yes bestie, that's your version check, use it.
the JSON output format is newly designed and has no limitation found in the default tags file format. let me say that again for the people in the back:
- the values for the
kindkey are represented in long-name flags. there is no one-letter situation here. none. zero. π - scope names and scope kinds have distinguished keys:
scopeandscopeKind. in the default tags file format they're combined β here they get to live their separate lives. main character energy for both. π
π§ DATA TYPE USED IN A FIELD π§
values for most of all the keys are represented in JSON string type. but some of them are represented in string, integer, and/or boolean type. it's a mixed bag, and honestly? it works.
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 is the one you wanna stare at β that's where the data types live. here's the decoder ring π₯
's'β string'i'β integer'b'β boolean (trueorfalse)
for an example, the value for the pattern field of ctags takes a string or a boolean value. see? told you. π
π°οΈ 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", }
π SEE ALSO π
ctags(1), tags(5), ctags-client-tools(7)
okay that's the whole page, bestie!! this was ctags-json-output(5) at version 1.0, coming to you straight from Universal Ctags π go forth and parse responsibly. bye bestie!! πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: universal-ctags 6.2.1-1 Β· GPL-2.0-or-later
- ubuntu stonking: universal-ctags 6.2.1-1 Β· 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