json2dcm(1)
π json2dcm(1) β OFFIS DCMTK girlie π
Bestie, welcome to the json2dcm(1) manual page from OFFIS DCMTK. This is the whole vibe: JSON goes in, DICOM comes out, and we keep every single detail because we don't do skipped options here. π
πΈ NAME πΈ
json2dcm β convert JSON document to DICOM file or data set. Literally what it says on the tin.
π¦ SYNOPSIS π¦
json2dcm [options] jsonfile-in dcmfile-out
π DESCRIPTION π
Okay so the json2dcm utility converts the contents of a JSON (JavaScript Object Notation) document to a binary DICOM file or data set. The JSON document is expected to conform to the "DICOM JSON Model" as defined in DICOM Part 18 Section F. Such JSON files can be created, e.g., using the dcm2json tool. Iconic little pipeline, no cap. β¨
π PARAMETERS π
jsonfile-inβ JSON input filename to be converted (-for stdin)dcmfile-outβ DICOM output filename (-for stdout)
β¨ OPTIONS β¨
π general options π
-h,--helpβ print this help text and exit--versionβ print version information and exit--argumentsβ print expanded command line arguments-q,--quietβ quiet mode, print no warnings and errors-v,--verboseβ verbose mode, print processing details-d,--debugβ debug mode, print debug information-ll,--log-level[l]evel: string constant β (fatal,error,warn,info,debug,trace) use level l for the logger-lc,--log-config[f]ilename: string β use config file f for the logger
π input options π
input file format:
+f,--read-meta-infoβ read meta information if present (default)-f,--ignore-meta-infoβ ignore file meta information
π§ processing options π§
unique identifiers:
+Ug,--generate-new-uidsβ generate new Study/Series/SOP Instance UID-Uo,--dont-overwrite-uidsβ do not overwrite existing UIDs (default)+Uo,--overwrite-uidsβ overwrite existing UIDs
bulkdata URI handling:
+Bu,--parse-bulkdata-uriβ parse Bulkdata URIs (default)-Bu,--ignore-bulkdata-uriβ ignore Bulkdata URIs+Bd,--add-bulkdata-dir[d]irectory: string β add d to list of permitted bulk data sources
handling of arrays with multiple data sets:
-ar,--array-rejectβ reject multiple data sets (default)+as,--array-select[n]umber: integer β select data set n from array+ar,--array-sequenceβ store all data sets in private sequence
charset handling:
+c,--charset-convertβ convert to the specific character set given in JSON (default)-c,--charset-utf8β write DICOM file with UTF-8 (ISO_IR 192), no conversion
π output options π
output file format:
+F,--write-fileβ write file format (default)-F,--write-datasetβ write data set without file meta information+Fu,--update-meta-infoβ update particular file meta information
output transfer syntax:
+t=,--write-xfer-sameβ write with same TS as input (default)+te,--write-xfer-littleβ write with explicit VR little endian TS+tb,--write-xfer-bigβ write with explicit VR big endian TS+ti,--write-xfer-implicitβ write with implicit VR little endian TS+td,--write-xfer-deflatedβ write with deflated explicit VR little endian TS
error handling:
-E,--stop-on-errorβ do not write if document is invalid (default)+E,--ignore-errorsβ attempt to write even if document is invalid
post-1993 value representations:
+u,--enable-new-vrβ enable support for new VRs (UN/UT) (default)-u,--disable-new-vrβ disable support for new VRs, convert to OB
length encoding in sequences and items:
+e,--length-explicitβ write with explicit lengths (default)-e,--length-undefinedβ write with undefined lengths
deflate compression level (only with --write-xfer-deflated):
+cl,--compression-level[l]evel: integer (default: 6) β0=uncompressed, 1=fastest, 9=best compression
π₯ NOTES π₯
The basic structure of the JSON input expected looks like the following (see DICOM Part 18 Section F for details):
{
"00080005": {
"vr": "CS",
"Value": [
"ISO_IR 192"
]
},
"00080020": {
"vr": "DT",
"Value": [
"20130409"
]
},
"00080030": {
"vr": "TM",
"Value": [
"131600.0000"
]
},
"00080050": {
"vr": "SH",
"Value": [
"11235813"
]
},
"00080056": {
"vr": "CS",
"Value": [
"ONLINE"
]
},
"00080061": {
"vr": "CS",
"Value": [
"CT",
"PET"
]
},
"00080090": {
"vr": "PN",
"Value": [
{
"Alphabetic": "^Bob^^Dr."
}
]
},
"00081190": {
"vr": "UR",
"Value": [
"http://wado.nema.org/studies/
1.2.392.200036.9116.2.2.2.1762893313.1029997326.945873"
]
},
"00090010": {
"vr": "LO",
"Value": [
"Vendor A"
]
},
"00091002": {
"vr": "UN",
"InlineBinary": "z0x9c8v7"
},
"00100010": {
"vr": "PN",
"Value": [
{
"Alphabetic": "Wang^XiaoDong"
}
]
},
"00100020": {
"vr": "LO",
"Value": [
"12345"
]
},
"00100021": {
"vr": "LO",
"Value": [
"Hospital A"
]
},
"00100030": {
"vr": "DA",
"Value": [
"19670701"
]
},
"00100040": {
"vr": "CS",
"Value": [
"M"
]
},
"00101002": {
"vr": "SQ",
"Value": [
{
"00100020": {
"vr": "LO",
"Value": [
"54321"
]
},
"00100021": {
"vr": "LO",
"Value": [
"Hospital B"
]
}
},
{
"00100020": {
"vr": "LO",
"Value": [
"24680"
]
},
"00100021": {
"vr": "LO",
"Value": [
"Hospital C"
]
}
}
]
},
"0020000D": {
"vr": "UI",
"Value": [
"1.2.392.200036.9116.2.2.2.1762893313.1029997326.945873"
]
},
"00200010": {
"vr": "SH",
"Value": [
"11235813"
]
},
"00201206": {
"vr": "IS",
"Value": [
4
]
},
"00201208": {
"vr": "IS",
"Value": [
942
]
}
}
π¦ Character Encoding π¦
The JSON format always uses UTF-8 encoding, but Specific Character Set (0008,0005) may specify the original encoding that was in use prior to conversion to JSON. By default, json2dcm will convert the encoding back to the given specific character set. This will fail if multiple character sets were in use, e.g. for the Japanese language:
"00080005": {
"vr": "CS",
"Value": [
"ISO 2022 IR 13",
"ISO 2022 IR 87"
]
},
In this case, use the --charset-utf8 option, which will write the DICOM file with UTF-8 (ISO_IR 192) encoding and not attempt any conversion. No conversion drama, just UTF-8. π
π§ Binary Data, Bulk Data, and Pixel Data π§
The DICOM JSON Model uses "InlineBinary" to store attribute values of binary value representations such as "OB", "OW", "OD", "OF", "OL", "OV" etc. in Base64 encoded form. This is supported in json2dcm for all binary attributes, including unencapsulated pixel data.
The DICOM JSON Model also permits attribute values to be stored separately from the JSON data set and to be referenced through a "BulkDataURI". This is supported for file URIs that reference files in the local filesystem. The json2dcm tool also supports the unofficial extension to the file URI scheme generated by DCM4CHE, where parameters named "offset" and "length" are appended to the file URI in order to refer to a specific part of a file. HTTP URIs as well as URIs that identify another part in a MIME multipart/related structure are not yet supported in json2dcm. If the command line option --ignore-bulkdata-uri is specified, then all bulk data URIs are ignored and attributes with bulk data will be written with empty value. Empty value era, but only when you asked for it.
Finally, encapsulated (in particular, compressed) pixel data is not supported by json2dcm because the syntax of the DICOM JSON Model for this specific case is not defined in the DICOM standard yet. Not a vibe yet, bestie β the standard hasn't defined it. π
π Arrays of Data Sets π
The DICOM JSON Model uses a JSON array structure to return multiple data sets in DICOMweb services such as WADO-RS or QIDO-RS. JSON arrays containing a single DICOM data set are automatically recognized by json2dcm and treated like a data set without the surrounding array structure. JSON arrays containing multiple data sets are rejected by default. Alternatively, the --array-select option can be used to select one data set from the array to be converted. The --array-sequence option causes all data sets to be written as sequence items into a single private sequence with attribute tag (0009,1000). Such files, which are mostly intended for debugging purposes, can be recognized by the private creator element (0009,0010), which has the value "JSON2DCM_LIST_OF_DATASETS". Private sequence with main character energy. π
π Trailing Commas π
Trailing commas are not permitted in JSON, but json2dcm will still accept such JSON data sets without warning or error message because they are handled gracefully by the underlying JSON parser. Users should, therefore, not assume that a JSON data set is valid just because json2dcm accepts it. This tool is not designed as a validator for JSON or the DICOM JSON Model. Do not use this as your JSON validator, bestie β it is not that girl. π
π LOGGING
ok so you can fully control how chatty the tools are, like both the command line tools and the libraries underneath them π The level of logging output of the various command line tools and underlying libraries can be specified by the user. By default? Only errors and warnings get written to the standard error stream. Nice and chill.
- Wanna see more? Hit
--verboseβ then you also get informational messages, like processing details, which is honestly kind of fun to watch. --debugis the deep-dive option: it gives you way more detail on the internal activity, e.g. for debugging purposes π- Other logging levels can be selected using
--log-level - And
--quietmode? Only fatal errors get reported. In such very severe error events, the application will usually terminate, so likeβ¦ bestie, be aware π
For more details on the different logging levels, see documentation of module "oflog". iykyk.
So what if you want that logging output going somewhere else? Say, to a file (optionally with logfile rotation), to syslog (Unix) or the event log (Windows)? That's what --log-config is for β¨ This configuration file also allows for directing only certain messages to a particular output stream, and for filtering certain messages based on the module or application where they are generated. Genuinely so much power. An example configuration file is provided in <etcdir>/logger.cfg β go peek, it's giving reference material π
π¬ COMMAND LINE
Okay this part is lowkey important so pay attention bestie π«Ά All command line tools use the following notation for parameters:
- square brackets enclose optional values (0-1)
- three trailing dots indicate that multiple values are allowed (1-n)
- a combination of both means 0 to n values
Command line options are distinguished from parameters by a leading + or - sign, respectively. Usually, order and position of command line options are arbitrary (i.e. they can appear anywhere). But β and this is the plot twist β if options are mutually exclusive, the rightmost appearance is used. This behavior conforms to the standard evaluation rules of common Unix shells. slay, consistent behavior π
Also you can be lazy in the best way: one or more command files can be specified using an @ sign as a prefix to the filename (e.g. @command.txt). Such a command argument is replaced by the content of the corresponding text file (multiple whitespaces are treated as a single separator unless they appear between two quotation marks) prior to any further evaluation. Ngl that's iconic.
β οΈ Please note that a command file cannot contain another command file. No inception, no recursion, we don't do that here π
This simple but effective approach allows one to summarize common combinations of options/parameters and avoids longish and confusing command lines. An example is provided in file <datadir>/dumppat.txt β literally go look, it's a whole vibe check π
πͺ EXIT CODES
The dcm2json utility uses the following exit codes when terminating. This enables the user to check for the reason why the application terminated. So if something goes sideways, the number tells you exactly what happened π₯
general
EXITCODE_NO_ERRORβ0EXITCODE_COMMANDLINE_SYNTAX_ERRORβ1
input file errors
EXITCODE_CANNOT_READ_INPUT_FILEβ20
output file errors
EXITCODE_CANNOT_WRITE_OUTPUT_FILEβ40
processing errors
EXITCODE_INVALID_JSON_CONTENTβ65EXITCODE_BULKDATA_URI_NOT_SUPPORTEDβ66EXITCODE_CHARSET_CONVERSION_FAILEDβ72
π± ENVIRONMENT
The json2dcm utility will attempt to load DICOM data dictionaries specified in the DCMDICTPATH environment variable.
By default β i.e. if the DCMDICTPATH environment variable is not set β the file <datadir>/dicom.dic will be loaded, unless the dictionary is built into the application (default for Windows). π»
The default behavior should be preferred, and the DCMDICTPATH environment variable only used when alternative data dictionaries are required. Like, don't touch it unless you have a reason, okay? π
Format stuff you gotta know:
- The
DCMDICTPATHenvironment variable has the same format as the Unix shellPATHvariable, in that a colon (:) separates entries. - On Windows systems, a semicolon (
;) is used as a separator.
The data dictionary code will attempt to load each file specified in the DCMDICTPATH environment variable. And heads up: it is an error if no data dictionary can be loaded π that one's not a drill.
π SEE ALSO
dcm2json(1)β the other half of this duo, go read it too π¦
Β©οΈ COPYRIGHT
Copyright (C) 2024-2026 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany. π«Ά
and that's the whole page bestie!! π this was Version 3.7.1, dated Sat Oct 17 2026 09:34:01 β screenshot it, bookmark it, tattoo it on your forearm, whatever works πβ¨ mwah π
π¦ where this page comes from
- arch rolling: dcmtk 3.7.1-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms