Dev Helpers
← Back

Split a path into fields

Split a path into fields using Node.js.

Open this example in the interactive library

Source code

import { posix as path } from "node:path";
console.log(path.parse("/var/log/app.log"));

Sample output

{
  root: '/',
  dir: '/var/log',
  base: 'app.log',
  ext: '.log',
  name: 'app'
}