Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Next release
``ValueError: did not find any 'pre_scan' hooks``.
https://github.com/aboutcode-org/scancode-toolkit/issues/5363

- Add a new CLI option for a compact JSON output with ``--compact-json``
https://github.com/aboutcode-org/scancode-toolkit/issues/4555

v33.0.0rc1 - 2026-05-14
------------------------

Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ FLOT_REQUIREMENTS="etc/thirdparty/flot-0.7.3-py3-none-any.whl"
VIRTUALENV_DIR=venv

# Cleanable files and directories to delete with the --clean option
CLEANABLE="build dist venv .cache .eggs *.egg-info docs/_build/ pip-selfcheck.json"
CLEANABLE="build tmp dist venv .cache .eggs *.egg-info docs/_build/ pip-selfcheck.json .pytest_cache .ruff_cache src/scancode_toolkit.egg-info"


# the URL to download virtualenv.pyz if needed
Expand Down
209 changes: 114 additions & 95 deletions docs/source/reference/scancode-cli/cli-help-text-options.rst

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions docs/source/reference/scancode-cli/cli-output-format-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,89 @@ Quick reference

----

.. _cli-compact-json-option:

``--compact-json FILE``
-----------------------

``--compact-json`` is an output format option which outputs the resusts in the most
compact manner possible. To make the output results compact:

* duplicate data is removed so we only have unique detection results only once
* only the most important data attributes are kept and the rest is removed
* longer text fields are either removed or CLI options adding longer/diangostic text
fields are made incompatible with the compact option
* empty data attributes are removed

The following code performs a scan on the samples directory, and publishes the results in
``compact-json`` format

.. code-block:: shell

scancode -clpieu --compact-json output.json samples

**Example**

.. code-block:: json

{
"path": "samples/JGroups/LICENSE",
"type": "file",
"size": 26430,
"date": "2022-04-20",
"sha1": "e60c2e780886f95df9c9ee36992b8edabec00bcc",
"md5": "7fbc338309ac38fefcd64b04bb903e34",
"sha256": "a190dc9c8043755d90f8b0a75fa66b9e42d4af4c980bf5ddc633f0124db3cee7",
"sha1_git": "b1e3f5a2638797271cbc9b91b856c05ed6942c8f",
"mime_type": "text/plain",
"file_type": "ASCII text",
"is_text": true,
"detected_license_expression_spdx": "LGPL-2.1-only",
"percentage_of_license_text": 100.0,
"copyrights": [
{
"copyright": "Copyright (c) 1991, 1999 Free Software Foundation, Inc.",
"start_line": 4,
"end_line": 4
},
{
"copyright": "copyrighted by the Free Software Foundation",
"start_line": 429,
"end_line": 429
}
],
"holders": [
{
"holder": "Free Software Foundation, Inc.",
"start_line": 4,
"end_line": 4
},
{
"holder": "the Free Software Foundation",
"start_line": 429,
"end_line": 429
}
],
"license_detections": [
{
"identifier": "lgpl_2_1-64dbac63-7b61-7151-023f-321235aeef62"
}
]
},
{
"path": "samples/JGroups/licenses",
"type": "directory",
"files_count": 5,
"size_count": 54552
}


This is the recommended output option if you want the output filesize to be as minimal as possible
while retaining the most important information in ScanCode-Toolkit.


---

.. _cli-json-lines-option:

``--json-lines FILE``
Expand Down
9 changes: 8 additions & 1 deletion docs/source/rst-snippets/cli-output-format-options.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
**Output formats**
------------------

--json FILE Write scan output as compact JSON to FILE.
--json FILE Write scan output as standard JSON to FILE.

--compact-json FILE Write scan output as compact JSON to FILE.
This output format only keeps the information
in scans which are most important parts,
removes any redundant information or empty
attributes to make the output as compact as
possible.

--json-pp FILE Write scan output as pretty-printed JSON to
FILE. This is one of the recommended output
Expand Down
4 changes: 2 additions & 2 deletions docs/source/rst-snippets/cli-output-to-stdout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Print to ``stdout`` / terminal
------------------------------

If you want to format the output in JSON and print it at stdout, you can replace the JSON filename
with a "-", like ``--json-pp -`` instead of ``--json-pp output.json``.
with a "-", like ``--compact-json -`` instead of ``--compact-json output.json``.

The following command will output the scan results in JSON format to ``stdout`` (in the terminal)::

./scancode -clpieu --json-pp - samples/
./scancode -clpieu --compact-json - samples/
2 changes: 2 additions & 0 deletions docs/source/tutorials/configuring-scan-output-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The following commands will output scan results in a formatted json file:

* ``scancode --json /path/to/output.json /path/to/target/dir``

* ``scancode --compact-json /path/to/output.json /path/to/target/dir``

* ``scancode --json-pp /path/to/output.json /path/to/target/dir``

* ``scancode --json-lines /path/to/output.json /path/to/target/dir``
Expand Down
3 changes: 2 additions & 1 deletion pyproject-scancode-toolkit-mini.toml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ ignore-copyrights = "cluecode.plugin_ignore_copyrights:IgnoreCopyrights"
[project.entry-points.scancode_output]
html = "formattedcode.output_html:HtmlOutput"
html-app = "formattedcode.output_html:HtmlAppOutput"
json = "formattedcode.output_json:JsonCompactOutput"
json = "formattedcode.output_json:JsonOutput"
compact-json = "formattedcode.output_json:JsonCompactOutput"
json-pp = "formattedcode.output_json:JsonPrettyOutput"
spdx-tv = "formattedcode.output_spdx:SpdxTvOutput"
spdx-rdf = "formattedcode.output_spdx:SpdxRdfOutput"
Expand Down
3 changes: 2 additions & 1 deletion pyproject-scancode-toolkit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ ignore-copyrights = "cluecode.plugin_ignore_copyrights:IgnoreCopyrights"
[project.entry-points.scancode_output]
html = "formattedcode.output_html:HtmlOutput"
html-app = "formattedcode.output_html:HtmlAppOutput"
json = "formattedcode.output_json:JsonCompactOutput"
json = "formattedcode.output_json:JsonOutput"
compact-json = "formattedcode.output_json:JsonCompactOutput"
json-pp = "formattedcode.output_json:JsonPrettyOutput"
spdx-tv = "formattedcode.output_spdx:SpdxTvOutput"
spdx-rdf = "formattedcode.output_spdx:SpdxRdfOutput"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ ignore-copyrights = "cluecode.plugin_ignore_copyrights:IgnoreCopyrights"
[project.entry-points.scancode_output]
html = "formattedcode.output_html:HtmlOutput"
html-app = "formattedcode.output_html:HtmlAppOutput"
json = "formattedcode.output_json:JsonCompactOutput"
json = "formattedcode.output_json:JsonOutput"
compact-json = "formattedcode.output_json:JsonCompactOutput"
json-pp = "formattedcode.output_json:JsonPrettyOutput"
spdx-tv = "formattedcode.output_spdx:SpdxTvOutput"
spdx-rdf = "formattedcode.output_spdx:SpdxRdfOutput"
Expand Down
Loading
Loading