path.sep

The platform-specific path segment separator.

Since Node 0.7 Spec ↗

Syntax

path.sep

Returns

string — POSIX: `/`. Windows: backslash.

Examples

import { sep } from 'node:path';

console.log('a' + sep + 'b');
Output
a/b
import { sep } from 'node:path';

const parts = '/usr/local/bin'.split(sep);
console.log(parts);
Output
[ '', 'usr', 'local', 'bin' ]

Notes

Prefer `path.join` and `path.parse` over manual splitting on `sep`. Use `path.posix.sep` or `path.win32.sep` when you need a fixed separator regardless of the host platform (e.g. for URLs).

See also