Library API
    Preparing search index...

    Function stripJSONC

    • Strips single-line (//) and multi-line (/* ... */) comments and trailing commas from a JSONC string. Preserves URLs and slashes within quoted strings.

      Parameters

      • text: string

        The JSONC formatted string to strip

      Returns string

      Cleaned JSON string ready for JSON.parse

      const cleanJson = stripJSONC('{\n  // comment\n  "key": "value",\n}');