# Syft vs Trivy vs cdxgen: which SBOM generator should you use?

URL: https://sbombox.com/blog/syft-vs-trivy-vs-cdxgen
By SBOMBox SBOM experts. Published 2026-11-11, updated 2026-11-17

> Syft, Trivy, cdxgen and Microsoft's sbom-tool compared: formats, strengths and the commands to try each free SBOM generator on your own build.

Short answer: use Trivy if you already run it for scanning, Syft if container images are your main artifact, and cdxgen if you have a polyglot source tree or monorepo. Then test the output, because the generator you pick changes what ends up in the SBOM.

## The three tools at a glance

- Syft (Anchore) is a dedicated SBOM cataloguer for container images, directories, files and archives. It is known for rich component metadata and pairs with Grype for vulnerability scanning.
- Trivy (Aqua Security) is a general security scanner that also emits SBOMs. If it is already in your pipeline, an SBOM is mostly a change of output flag.
- cdxgen (OWASP CycloneDX project) is CycloneDX-first and supports a very wide range of languages and build systems, which suits monorepos and mixed stacks.

All three can produce CycloneDX, and Syft and Trivy can also produce SPDX. If you are still choosing a format, read [CycloneDX or SPDX? A practical way to choose](https://sbombox.com/blog/cyclonedx-vs-spdx-which-to-pick).

## Try each one on your own code

1. **Syft - scan a directory or image.** Point it at your source directory or a built image and write CycloneDX JSON.

   ```
   syft dir:. -o cyclonedx-json=sbom.syft.cdx.json
   syft your-image:tag -o cyclonedx-json=image.cdx.json
   ```
2. **Trivy - reuse your scanner.** The fs target scans a directory; image scans a container image.

   ```
   trivy fs --format cyclonedx --output sbom.trivy.cdx.json .
   trivy image --format cyclonedx --output image.cdx.json your-image:tag
   ```
3. **cdxgen - polyglot source trees.** Run it at the repository root. It detects the project types it finds.

   ```
   cdxgen -o sbom.cdxgen.cdx.json .
   ```
4. **Compare the results.** Score all three files and compare component counts, versions, hashes and licences. Pick the one that is most complete for your stack, not the one with the most stars.

## Why the results differ

Each tool reads different evidence: lock files, package manager metadata, installed files in an image, or the build itself. An SBOM made from a source directory may miss what the build pulls in; one made from an image may miss build-only dependencies. Academic work comparing Syft and Trivy on the same Docker images found that changing only the generator changed the vulnerabilities reported. Generate from the artifact you actually ship, and generate at build time when you can.

## What to check in the output

- Exact versions for every component, not ranges.
- Package URLs (purls), so vulnerability databases can match components.
- Transitive dependencies and the dependency graph, not just a flat list.
- Hashes, licences and producer names, which CISA's 2026 minimum elements and Germany's BSI TR-03183-2 now expect.
- The tool name and version in the SBOM metadata, so you can reproduce it.

## What about Microsoft's SBOM Tool?

Microsoft's sbom-tool is a free, open-source generator (MIT licence) that Microsoft uses for its own builds. It writes SPDX only, not CycloneDX, and it is designed to run on a build's output folder: it records the files you ship with their hashes, plus the packages it detects in your source. That makes it a good fit for .NET and Windows-centric pipelines and for teams that standardise on SPDX.

```bash
sbom-tool generate -b ./out -bc . -pn example-api -pv 1.4.0 -ps "Example Ltd" -nsb https://example.com
# writes ./out/_manifest/spdx_2.2/manifest.spdx.json
```

**Four free SBOM generators compared**

| Tool | Formats | Best for |
| --- | --- | --- |
| Syft | CycloneDX, SPDX | Container images and directories |
| Trivy | CycloneDX, SPDX | Teams already scanning with Trivy |
| cdxgen | CycloneDX | Polyglot repositories and monorepos |
| Microsoft sbom-tool | SPDX | Build-output SBOMs, .NET and SPDX-first teams |

Need CycloneDX from an SPDX-only tool? Convert it with the free [SBOM converter](https://sbombox.com/tools/sbom-converter).

## Where SBOMBox fits

SBOMBox does not replace these generators. The `sbombox` CLI runs generation in your environment, then scores, signs and stores the result per release and monitors it for new vulnerabilities. You can also upload an SBOM from any of the three tools. See the [install guide](https://sbombox.com/docs/install).
