NSFW JS

NSFW JS is a JavaScript library designed to help identify potentially inappropriate images on a client's browser, without needing to send the image to a server.

Last verified:

Visit NSFW JS

What is NSFW JS?

NSFW JS is a JavaScript library for detecting potentially inappropriate images directly in the browser, so images do not need to be sent to a server. It uses TensorFlow.js and a pre-trained model to classify images into five categories: Drawing, Hentai, Neutral, Porn, and Sexy.

The project is built for client-side content filtering, which makes it useful when you want to screen uploads, user-generated content, or images already loaded on a page. It supports common browser image inputs such as <img>, <canvas>, and <video>, and returns probability scores so you can decide how strict your filtering should be.

NSFW JS includes multiple model options with different tradeoffs, including MobileNetV2, MobileNetV2Mid, and InceptionV3. The repository also describes caching support, hosted-model options, production guidance, and examples for browser, React Native, and Node.js usage.

It is aimed at developers, website administrators, and teams that need lightweight moderation or safety filtering without a server round trip. The project is open source under the MIT license and is positioned as a free tool that can be modified and deployed in commercial or personal projects.

NSFW JS pricing

Pricing model: Free

NSFW JS is free and open source under the MIT license, with no paid tiers listed on the website. The GitHub repository says it is free to use and always will be, and the project notes that Infinite Red offers premium training and support separately for organizations that need expert help.

NSFW JS pros

  • Client-side image detection
  • No server upload required
  • Uses TensorFlow.js
  • Open source MIT license
  • Free to use
  • Five-class image classification
  • Returns probability scores
  • Supports custom thresholds
  • Works with <img> elements
  • Works with <canvas> elements
  • Works with <video> elements
  • Multiple bundled models
  • Model size options available
  • Supports browser caching
  • Can host models yourself
  • Has browser demo
  • Has React Native example
  • Has Node.js example
  • Supports production deployment guidance
  • Allows reporting false positives

NSFW JS cons

  • Only detects images, not text
  • Requires JavaScript to run
  • Depends on TensorFlow.js
  • Accuracy is not perfect
  • False positives can happen
  • Model loading adds initial overhead
  • Some models are relatively large
  • Hosted model setup takes work
  • Browser support may vary
  • Mobile demo is not a full app

Frequently asked questions about NSFW JS

What does NSFW JS do?

NSFW JS is a client-side JavaScript library that classifies images as potentially safe or unsafe by running TensorFlow.js models in the browser. It is designed to help detect inappropriate content without sending images to a server.

Which image categories does it use?

The library classifies images into five categories: Drawing, Hentai, Neutral, Porn, and Sexy. Those labels let you distinguish between safe artwork, neutral images, sexually explicit drawings, pornographic content, and sexually explicit photos.

Does NSFW JS work in the browser only?

Its main use case is browser-side detection, but the documentation also shows Node.js usage with tfjs-node. The repository includes examples for browser apps, React Native, and server-side classification.

What models are available?

The repository lists three bundled model options: MobileNetV2, MobileNetV2Mid, and InceptionV3. Each model has different size and accuracy tradeoffs, and you can also host model files yourself.

Can I host the model myself?

Yes. The documentation explains that you can download the model files, place them on your own server or static host, and point nsfwjs.load() to your hosted model.json file. This is presented as a way to reduce bundle size and improve loading control.

How accurate is it?

The website materials describe the model as being around 90% to 93% accurate depending on the model used. The project also notes that it is not perfect and can produce false positives.

What inputs can I classify?

The classify method accepts browser-based image inputs such as image elements, video elements, canvas elements, and tensor or image data inputs. The repository says you can request the top results or all available class probabilities.

Is there a demo?

Yes. The project says the live demo at nsfwjs.com is powered by the example app in the examples/nsfw_demo folder. The repository and third-party listings also mention a mobile demo for testing images on mobile devices.

Is NSFW JS free to use commercially?

Yes. The project is MIT licensed, which means it is free to use, modify, and distribute, including in commercial projects. The site materials explicitly describe it as free and open source.

How do I integrate it into an app?

The repository shows that you install TensorFlow.js as a peer dependency, install nsfwjs, load a model with nsfwjs.load(), and then call model.classify() on an image element or other supported input. It also provides production guidance and examples for browser, Node.js, and React Native integration.

Categories

Use cases

Browse all AI tools on NeedAnAI