# Path lexical normalize

`path-lexical-normalize` · version 1.0.0 · File paths (lexical) · free, no key needed

Normalize a path lexically: collapse redundant separators, resolve "." and ".." segments.

**Use when you need to: path normalize · normalize file path · collapse dot segments.**

## Supported

- path normalize
- normalize file path
- collapse dot segments
- resolve dot dot

## Not supported

- stat file
- resolve symlinks
- filesystem access

## Behavior

- Collapse redundant separators and resolve "." and ".." via lexicalNormalize.
- If allow_above_root is false and normalized result has leading ".." for a relative path, reject with badInput.
- changed: normalized !== original input string.

## Input

- `path` (string, required): min length 1; max length 4096
- `format` (one of "posix", "windows", "auto", optional)
- `allow_above_root` (boolean, optional)

## Output

- `normalized` (string, required)
- `format` (one of "posix", "windows", required)
- `is_absolute` (boolean, required)
- `changed` (boolean, required)

## Limits

- max path bytes: 4096

## Example

Request input:

```json
{
  "path": "/a/b/../c/./d"
}
```

Response:

```json
{
  "result": {
    "normalized": "/a/c/d",
    "format": "posix",
    "is_absolute": true,
    "changed": true
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "path-lexical-normalize",
  "version": "1.0.0",
  "input": {
    "path": "/a/b/../c/./d"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/path-lexical-normalize/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"path":"/a/b/../c/./d"}'
```

The machine-readable contract is at [/v1/tools/path-lexical-normalize/versions/1.0.0](/v1/tools/path-lexical-normalize/versions/1.0.0).

### CLI

```sh
node cli.mjs run path-lexical-normalize 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Path lexical join](/tools/path-lexical-join): Join an array of path segments lexically, resolving absolute reset boundaries and normalizing separators.
- [Path lexical parse](/tools/path-lexical-parse): Decompose a file path into its lexical components without accessing the filesystem.
- [Path lexical common ancestor](/tools/path-lexical-common-ancestor): Compute the deepest common ancestor directory of a set of paths.
- [Path lexical contains](/tools/path-lexical-contains): Check whether a child path is lexically inside a parent directory.
- [Path lexical relative](/tools/path-lexical-relative): Compute the lexical relative path from one path to another without filesystem access.
- [Path lexical sanitize](/tools/path-lexical-sanitize): Sanitize an untrusted path to produce a safe relative path, stripping roots, drive letters, traversal segments, and illegal characters.
