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

# Compare Block

> Perform comparison operations between two input values

<Frame>
  <img src="https://mintcdn.com/odella/MNHyQg3-ZFMTYSp3/block-reference/assets/compare_light.png?fit=max&auto=format&n=MNHyQg3-ZFMTYSp3&q=85&s=7b1fd599371e4a7992bc09b8b30de0b1" alt="Compare Block Screenshot" className="block dark:hidden" width="556" height="334" data-path="block-reference/assets/compare_light.png" />

  <img src="https://mintcdn.com/odella/MNHyQg3-ZFMTYSp3/block-reference/assets/compare_dark.png?fit=max&auto=format&n=MNHyQg3-ZFMTYSp3&q=85&s=a07a299bec3eaec2bff6aa5f8157dadd" alt="Compare Block Screenshot" className="hidden dark:block" width="536" height="356" data-path="block-reference/assets/compare_dark.png" />
</Frame>

## Overview

The Compare Block allows you to perform comparison operations between two input values. It supports various comparison functions including equality, inequality, less than, greater than, and logical operations such as AND, OR, XOR, NAND, NOR, and XNOR.

## Inputs

<ParamField path="A" type="any">
  The first value for comparison. Required.
</ParamField>

<ParamField path="B" type="any">
  The second value for comparison. Required.
</ParamField>

<ParamField path="Comparison Function" type="string">
  The comparison function to use. Only available when "Use Comparison Function Input" is enabled in settings.
</ParamField>

## Outputs

<ResponseField name="Output" type="boolean">
  The result of the comparison operation.
</ResponseField>

## Editor Settings

<ParamField path="Comparison Function" type="string" default="==">
  The comparison function to be used for the operation. Available options are:

  * `==`: Equal to
  * `!=`: Not equal to
  * `<`: Less than
  * `>`: Greater than
  * `<=`: Less than or equal to
  * `>=`: Greater than or equal to
  * `and`: Logical AND
  * `or`: Logical OR
  * `xor`: Logical XOR
  * `nand`: Logical NAND
  * `nor`: Logical NOR
  * `xnor`: Logical XNOR
</ParamField>

<ParamField path="Use Comparison Function Input" type="boolean" default={false}>
  When enabled, adds a "Comparison Function" input port that can override the comparison function setting.
</ParamField>

## Example: Compare two numbers

1. Create a Compare Block and set the `Comparison Function` to `>`.
2. Create two Number Blocks, one with the value `5` and the other with the value `3`.
3. Connect the Number Blocks to the `A` and `B` inputs of the Compare Block respectively.
4. Run the flow. The output of the Compare Block will be `true`, because 5 is greater than 3.

## Error Handling

If input A is not provided:

* For `==` comparison: Returns `true` if B is also not provided, `false` otherwise
* For `!=` comparison: Returns `true` if B is provided, `false` otherwise
* For all other comparisons: Returns `false`

If the inputs are not of the same type, the block will attempt to coerce the second input (`B`) to the type of the first input (`A`).

## FAQ

<AccordionGroup>
  <Accordion title="What happens if the inputs are not of the same type?">
    If the inputs are not of the same type, the block will attempt to coerce the second input (`B`) to the type of the first input (`A`). If the coercion is not possible, the comparison will be performed with the original values.
  </Accordion>

  <Accordion title="Can I use the Compare Block to compare arrays or objects?">
    Yes, you can use the Compare Block to compare arrays or objects. The comparison will be performed using a deep equality check that compares all nested values.
  </Accordion>
</AccordionGroup>

## See Also

* [If Block](/block-reference/logic/if-else)
* [Match Block](/block-reference/logic/match)
* [Code Block](/block-reference/advanced/code)
