Node.js path.delimiter Property

Last Updated : 4 Aug, 2026

The path.delimiter property in Node.js is a built-in value from the path module that provides the correct path separator for the current operating system. It helps keep path-related code consistent across different platforms.

  • The delimiter depends on the operating system.
  • It is part of the path module.
  • It is commonly used when handling multiple paths in a platform-aware way.

Syntax

path.delimiter;

where,

  • path: The Node.js path module.
  • delimiter: A property that provides the platform-specific path delimiter.

Return Value: Returns a string representing the platform-specific path delimiter.

  • On Windows, the delimiter is ;.
  • On Linux and macOS, the delimiter is : .

Example 1:

javascript
// Node.js program to demonstrate the   
// path.delimiter property

// Allocating path module
const path = require('path');

// Printing path.delimiter value
console.log(path.delimiter);

In this code, path.delimiter is used to display the path-list separator used by the current operating system.

Output:

;

Example 2:

javascript
// Node.js program to demonstrate the   
// path.delimiter property

// Allocating path module
const path = require('path');

// Allocating process module
const process = require('process');
 
// Printing path.delimiter value
var delimiter = path.delimiter;
 
console.log(process.env.PATH);
console.log(process.env.PATH.split(path.delimiter));

In this code, path.delimiter is used to split the system PATH environment variable into individual path entries.

Output:

C:\wamp64\bin\php\php7.3.1\ext\ImageMagick;C:\Program Files (x86)\Common 
Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\OpenSSH\;D:\programfiles\Git\cmd;
D:\programfiles\Cmake\bin;
C:\Program
Files\nodejs\;C:\Users\gekcho\AppData\Local\Microsoft\WindowsApps;
C:\Users\gekcho\AppData\Roaming\npm
[ 'C:\\wamp64\\bin\\php\\php7.3.1\\ext\\ImageMagick',
'C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath',
'C:\\Windows\\system32',
'C:\\Windows',
'C:\\Windows\\System32\\Wbem',
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\',
'C:\\Windows\\System32\\OpenSSH\\',
'D:\\programfiles\\Git\\cmd',
'D:\\programfiles\\Cmake\\bin',
'C:\\Program Files\\nodejs\\',
'C:\\Users\\gekcho\\AppData\\Local\\Microsoft\\WindowsApps',
'C:\\Users\\gekcho\\AppData\\Roaming\\npm' ]

Use Cases of path.delimiter

  • Split environment variable paths: Separates directory entries stored in variables such as PATH.
  • Create path-based environment variables: Joins multiple directory paths into a single environment variable value.
  • Cross-platform path handling: Uses the appropriate path-list separator for the current operating system.
  • Validate path entries: Checks and manages individual directories contained within path-list strings.

Reference: https://nodejs.org/api/path.html#path_path_delimiter

Comment

Explore