> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scanoss.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Snippet Match Percentage

> Snippets are short pieces of code that might come from different public sources such as GitHub, GitLab or Stack Overflow. The snippet match percentage is a key metric in Software Composition Analysis (SCA) that indicates how much of your scanned file matches known open source code in the knowledge base.

## Understanding Snippet Match Percentage

The snippet match percentage represents the proportion of your scanned file that matches known open source code.

This metric helps you understand:

* How much of your code is derived from or similar to existing open source components
* The degree of similarity between your code and components in the knowledge base
* Whether you need to review licensing and compliance requirements

### Calculation Method

The match percentage is calculated using the following formula:

`Matched Percentage = (Matched Snippet Lines / Total File Lines) × 100`

**Example Calculation:**

Consider a file with the following characteristics:

* Total file lines: 2,557
* Matched snippet lines: 2,335

The snippet match percentage would be:

`(2,335 ÷ 2,557) × 100 = 91%`

This means that SCANOSS was able to match 91% of the scanned file against known open source code in the knowledge base.

## Determining Matched Snippet Lines

After scanning, the results are stored in a `results.json` file. Within this file, each matched snippet includes a `lines` field that specifies the range of lines matched in the original file.

For example:

`"lines": "36-1082"`

This indicates that lines 36 through 1082 of the file were matched against open source components in the SCANOSS knowledge base.

To calculate the total number of matched lines for this snippet:

`Matched Snippet Lines = End Line - Start Line + 1`

> The `+1` is required because the range is inclusive of both the start and end lines. In the example above:

**Example calculation:**

`1082 - 36 + 1 = 1047 Matched Lines`

These matched lines are then used to calculate the match percentage:

`Matched Percentage = (1047/1083) × 100 = 96%`

Snippet match percentages help you assess how much of your code aligns with known open source.
