# TypeQL Syntax Checker

`typeql-check` is a small CLI tool that validates the syntax of a TypeQL query without sending it to a TypeDB server. It parses the input and exits with a non-zero status if the query is malformed, printing the parse error to stderr.

Use it to lint `.tql` files in editors and CI pipelines, or to sanity-check queries before running them against a database.

## [](#_installation)Installation

`typeql-check` is distributed through the same channels as TypeDB Console. For installation instructions, see the [Install TypeQL Syntax Checker](../../home/install/typeql-check/index.md) install page.

## [](#_usage)Usage

`typeql-check` reads a query from its first argument, or from standard input if no argument is given.

```bash
typeql-check "<query>"
```

```bash
typeql-check < query.tql
```

The exit code is:

*   `0` — the query parsed successfully (no output).
    
*   `1` — the query failed to parse (error printed to stderr).
    
*   `2` — an I/O error occurred while reading from stdin (for example, a broken pipe).
    

## [](#_examples)Examples

Check a query passed as an argument:

```bash
$ typeql-check "match $p isa person; fetch { 'name': $p.name };"
$ echo $?
0
```

Check a query from a file:

```bash
$ typeql-check < schema.tql
$ echo $?
0
```

Catch a syntax error:

```bash
$ typeql-check "match $p isa person fetch { 'name': $p.name };"
[TQL03] TypeQL Error: There is a syntax error
  parsing error: expected relation, comparator, expression, expression_struct, or value_literal
  Near 1:20:
  --> match $p isa person fetch { 'name': $p.name };

$ echo $?
1
```

Use in a shell pipeline:

```bash
$ cat query.tql | typeql-check && typedb console --command "..."
```

[TypeDB Loader Reference](../loader/reference/index.md) [TypeDB Admin Tool](../admin/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/tools/modules/ROOT/pages/typeql-check.adoc) Edit this page on GitHub.