# Path format convert

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

Convert file paths between POSIX and Windows formats, handling slashes, drive letters, and roots lexically.

**Use when you need to: path format convert · posix to windows path · windows to posix path.**

## Supported

- path format convert
- posix to windows path
- windows to posix path
- path separator convert

## Not supported

- stat file
- resolve symlinks
- filesystem access
- add drive letter

## Behavior

- posix->windows: replace / with \, prepend \ if starts with / making it a rooted-but-driveless Windows path. windows->posix: replace \ with /, drive letter C:\ becomes /c/ (lowercase), UNC \\server\share -> //server/share. Does not resolve . or .. further. changed:false when input is already in target format.

## Input

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

## Output

- `converted` (string, required)
- `from` (string, required)
- `to` (string, required)
- `changed` (boolean, required)

## Limits

- max path bytes: 4096

## Example

Request input:

```json
{
  "path": "/usr/local/bin",
  "to": "windows"
}
```

Response:

```json
{
  "result": {
    "converted": "\\usr\\local\\bin",
    "from": "posix",
    "to": "windows",
    "changed": true
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "path-format-convert",
  "version": "1.0.0",
  "input": {
    "path": "/usr/local/bin",
    "to": "windows"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/path-format-convert/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"path":"/usr/local/bin","to":"windows"}'
```

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

### CLI

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

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

## Related tools

- [Path lexical relative](/tools/path-lexical-relative): Compute the lexical relative path from one path to another without filesystem access.
- [Path set hierarchy tree](/tools/path-set-hierarchy-tree): Transform a flat array of file paths into a nested deterministic directory tree structure.
- [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 join](/tools/path-lexical-join): Join an array of path segments lexically, resolving absolute reset boundaries and normalizing separators.
- [Path lexical normalize](/tools/path-lexical-normalize): Normalize a path lexically: collapse redundant separators, resolve "." and ".." segments.
