Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including source-map-url with all npm packages installed. Try it out:

var sourceMapUrl = require("source-map-url")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

source-map-url v0.4.0

Tools for working with sourceMappingURL comments.

Overview Build Status

browser support

Tools for working with sourceMappingURL comments.

var sourceMappingURL = require("source-map-url")

var code = [
  "/*# */"

// true


code = sourceMappingURL.insertBefore(code, "// License: MIT\n")
// !function(){...}();
// // License: MIT
// /*# */

code = sourceMappingURL.removeFrom(code)
// !function(){...}();
// // License: MIT

// false

// null

code += "//# sourceMappingURL=/other/"
// !function(){...}();
// // License: MIT
// //# sourceMappingURL=/other/


  • npm install source-map-url
  • bower install source-map-url
  • component install lydell/source-map-url

Works with CommonJS, AMD and browser globals, through UMD.



Returns the url of the sourceMappingURL comment in code. Returns null if there is no such comment.


Returns true if there is a sourceMappingURL comment in code, or false otherwise.


Removes the sourceMappingURL comment in code. Does nothing if there is no such comment. Returns the updated code.

sourceMappingURL.insertBefore(code, string)

Inserts string before the sourceMappingURL comment in code. Appends string to code if there is no such comment.

Lets you append something to a file without worrying about burying the sourceMappingURL comment (by keeping it at the end of the file).


The regex that is used to match sourceMappingURL comments. It matches both // and /**/ comments, thus supporting both JavaScript and CSS.


Start by running npm test, which lints the code and runs the test suite in Node.js.

To run the tests in a browser, run testling (npm install -g testling) or testling -u.


The X11 (“MIT”) License.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free