DICOM Command Line Tools - CodeSwordsman

Everyday DCMTK and dcm4che command line tools for dumping, converting, transferring and anonymizing files.

DCMTK 3.6.8+ / dcm4che 5.xUpdated 2026-10-2937 commands

Dump & Inspect

Dump every tag with its VR and value; always the first step when debugging

dcmdump image.dcm

Print only the given tag; repeat +P to select several tags

dcmdump +P 0010,0010 image.dcm

Skip loading very long values such as pixel data for faster dumps

dcmdump -M image.dcm

Print long values completely; by default they are shortened

dcmdump +L image.dcm

Print the hierarchy as a tree, showing sequences and nested items

dcmdump +T image.dcm

Convert values affected by Specific Character Set to UTF-8 for readable output

dcmdump +U8 image.dcm

Format & Transfer Syntax

Write Explicit VR Little Endian, the most widely supported transfer syntax

dcmconv +te in.dcm out.dcm

Compressed pixel data needs a codec; conversion fails without one

Write Implicit VR Little Endian, common for legacy PACS and media

dcmconv +ti in.dcm out.dcm

Write Explicit VR Big Endian, only needed by a few legacy devices

dcmconv +tb in.dcm out.dcm

Write Deflated Explicit VR Little Endian to shrink the dataset

dcmconv +td in.dcm out.dcm

Export a PNG preview; dcm2pnm is the older name of the same tool

dcm2img +on image.dcm slice.png

Export a lossy baseline JPEG, handy for thumbnails

dcm2img +oj image.dcm slice.jpg

Wrap a plain JPEG or BMP image into DICOM using a template dataset

img2dcm -df template.dcm photo.jpg photo.dcm

Build the template with dump2dcm from a dump text file first

Networking & Query

Send a C-ECHO to verify connectivity and AE title configuration

echoscu -aet ECHO -aec PACS 10.0.0.12 11112

Query by patient name; -P selects the Patient Root information model

findscu -P -k 0010,0010="DOE^JOHN" 10.0.0.12 11112

Query studies by patient ID and a study date range

findscu -S -k 0010,0020=ID123 -k 0008,0020=20260101-20261231 10.0.0.12 11112

Extract the responses as rsp0001.dcm and following files

findscu -P -k 0010,0010 -X 10.0.0.12 11112
Risky

Send images; pointing it at a live PACS writes into the archive

storescu -aet SCU -aec STORAGE 10.0.0.12 11112 image.dcm

Check the peer with echoscu first, then send a small batch

Receive images locally and store them into the given directory

storescp -aet STORAGE -od /data/incoming 11112

The output directory must already exist, otherwise receiving fails

Retrieve a whole study from the PACS by its Study Instance UID

movescu -P -k 0020,000D=1.2.840.113619 -aem STORESCP -od /data 10.0.0.12 11112

Modify & Anonymize

Risky

Change the patient name in place, rewriting the original file

dcmodify -m "(0010,0010)=ANONYMOUS" image.dcm

A .bak copy is created by default; delete it after verifying

Risky

Rewrite the patient ID of every *.dcm in place; this cannot be undone

dcmodify -m "(0010,0020)=ANON-001" *.dcm
Risky

Erase the birth date element from the file; erasure is permanent

dcmodify -e "(0010,0030)" image.dcm
Risky

Erase all private data from the file, a must for real de-identification

dcmodify -ep image.dcm

Private tags often still hold device and patient information

Risky

Generate new Study, Series and SOP Instance UIDs for the file

dcmodify -gst -gse -gin image.dcm

After changing UIDs, update the index and all referring records

Risky

Disable the backup and rewrite the file; there is no way back

dcmodify -nb -m "(0008,1030)=CT Head" image.dcm

Validate & Compare

Validate mandatory attributes and encoding errors against the IOD

dciodvfy image.dcm

Shipped with dicom3tools, not part of the DCMTK package

Quickly inspect the file meta information and transfer syntax

dcmdump image.dcm | head -n 20

Re-encoding once exposes structural damage in the dataset

dcmconv +te in.dcm check.dcm

Keep printing even on parse errors, which helps diagnose broken files

dcmdump +E image.dcm

Diff two tag dumps to locate exactly what changed

dcmdump -M a.dcm > a.txt && dcmdump -M b.dcm > b.txt && diff a.txt b.txt

dcm4che Toolset

dcm4che passes the peer as AE@host:port via -c, unlike DCMTK

storescu -c STORAGE@10.0.0.12:11112 image.dcm

dcm4che uses -m for matching keys and -L to pick the query level

findscu -c PACS@10.0.0.12:11112 -L STUDY -m PatientID=12345678

Write DICOM JSON to stdout, with pixel data as a bulkdata reference

dcm2json image.dcm > image.json

The tool writes to stdout, so redirect it to save a file

Pretty-print the JSON with indentation for diffing and review

dcm2json -I image.dcm > image.json

Encode DS and IS values as JSON numbers instead of strings

dcm2json -N image.dcm > image.json

Inline bulkdata such as pixel data, which can blow up the JSON size

dcm2json -b image.dcm > image.json

Avoid it for large series; the output may reach hundreds of MB

Related tools

This website uses cookies to ensure you get the best experience on our website. Privacy Policy.