🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mso-conditional-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mso-conditional-parser

Parser and translator for MSO (Outlook) conditional comments in HTML email

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
146
-33.64%
Maintainers
1
Weekly downloads
 
Created
Source

mso-conditional-parser

Parser and translator for MSO (Outlook) conditional comments in HTML email.

Parses all real-world MSO comment patterns, validates conditions against known Outlook versions and operators, and translates them into human-readable English.

Used as the core engine by eslint-plugin-mso-conditionals and the MSO Conditional Comments VS Code extension.

Installation

npm install mso-conditional-parser

Requires Node.js 18+. ES module only ("type": "module").

API

parseMsoComment(str)

Parses an MSO conditional comment opener.

Returns a result object or null if the input is not a recognised MSO opener.

import { parseMsoComment } from 'mso-conditional-parser';

parseMsoComment('<!--[if gte mso 16]>');
// {
//   type: 'downlevel-hidden',
//   condition: 'gte mso 16',
//   translation: 'Outlook 2016, 2019, and 365 and newer',
//   isValid: true
// }

parseMsoComment('<!--[if mos]>');
// {
//   type: 'downlevel-hidden',
//   condition: 'mos',
//   translation: 'mos',
//   isValid: false,
//   error: "Typo detected: 'mos' should be 'mso'"
// }

Supported opener patterns:

PatternType
<!--[if mso]>downlevel-hidden
<!--[if gte mso 16]>downlevel-hidden
<!--[if !mso]><!--downlevel-revealed
<![if !mso]>downlevel-revealed (non-standard)

Result shape:

FieldTypeDescription
typestring'downlevel-hidden' or 'downlevel-revealed'
conditionstringRaw condition string extracted from the comment
translationstringHuman-readable English translation
isValidbooleantrue if the condition is syntactically valid
errorstringPresent when isValid is false

parseMsoEndComment(str)

Parses an MSO conditional comment closer.

Returns { type, isClosing: true } or null if not recognised.

import { parseMsoEndComment } from 'mso-conditional-parser';

parseMsoEndComment('<![endif]-->');
// { type: 'downlevel-hidden-end', isClosing: true }

parseMsoEndComment('<![endif]>');
// { type: 'downlevel-revealed-end', isClosing: true }

translateCondition(condition)

Translates a raw condition string into English without full parsing.

import { translateCondition } from 'mso-conditional-parser';

translateCondition('gte mso 16');  // 'Outlook 2016, 2019, and 365 and newer'
translateCondition('!mso');        // 'non-Outlook email clients'
translateCondition('mso 12');      // 'Outlook 2007'

isMsoComment(str)

Returns true if the string is any MSO comment — opener or closer.

import { isMsoComment } from 'mso-conditional-parser';

isMsoComment('<!--[if mso]>');   // true
isMsoComment('<![endif]-->');    // true
isMsoComment('<p>hello</p>');    // false

Supported conditions

SyntaxExampleMeaning
mso<!--[if mso]>Any Outlook version
!mso<!--[if !mso]><!--Non-Outlook clients
mso <version><!--[if mso 16]>Exact Outlook version
<op> mso <version><!--[if gte mso 14]>Version comparison
!mso <version><!--[if !mso 16]>Not this version
Compound & / |<!--[if (gt mso 9)&(lte mso 11)]>AND / OR

Valid operators: gte, gt, lte, lt, eq

Valid Outlook versions: 9 (2000), 10 (2002), 11 (2003), 12 (2007), 14 (2010), 15 (2013), 16 (2016/2019/365)

Note: there is no MSO version 13 — Outlook skips from 12 (2007) to 14 (2010).

License

MIT

Keywords

mso

FAQs

Package last updated on 07 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts