Split an email address into its local and domain parts

Usage no npm install needed!

<script type="module">
  import emailSplit from '';


email-split Build status

Split an email address into its local and domain parts

This was built to grab the name used off of an email address. This library does not perform validation as we retrieve our email addresses from a trusted source.

Getting Started

Install the module with: npm install email-split

var emailSplit = require('email-split');
emailSplit(''); /*
  local: 'todd',
  domain: ''


We expose the function emailSplit as our module.exports.


Function that extracts local and domain parts of email address.

  • email String - Email address to break down


  • retVal Object|null - If the email does not contain an @, then we return null. Otherwise, we return an Object.
    • An @ is required in a valid email address. We have decided to return null for consistency with Array.match and String.split behaviors.
    • local String - Leading portion of email address
      • For example, todd in
    • domain String - Tailing portion of email address
      • For example, in

We chose the names local and domain based off of the RFC specification for mailto.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint and test via npm test.


Copyright (c) 2015

Licensed under the MIT license.