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 babel-plugin-transform-class-properties with all npm packages installed. Try it out:

var babelPluginTransformClassProperties = require("babel-plugin-transform-class-properties")

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

babel-plugin-transform-class-properties v6.24.1

This plugin transforms static class properties as well as properties declared with the property initializer syntax


This plugin transforms es2015 static class properties as well as properties declared with the es2016 property initializer syntax.


Below is a class with four class properties which will be transformed.

  class Bork {
    //Property initializer syntax
    instanceProperty = "bork";
    boundFunction = () => {
      return this.instanceProperty;

    //Static class properties
    static staticProperty = "babelIsCool";
    static staticFunction = function() {
      return Bork.staticProperty;

  let myBork = new Bork;

  //Property initializers are not on the prototype.
  console.log(myBork.prototype.boundFunction); // > undefined

  //Bound functions are bound to the class instance.
  console.log(; // > "bork"

  //Static function exists on the class.
  console.log(Bork.staticFunction()); // > "babelIsCool"


npm install --save-dev babel-plugin-transform-class-properties


Via .babelrc (Recommended)


// without options
  "plugins": ["transform-class-properties"]

// with options
  "plugins": [
    ["transform-class-properties", { "spec": true }]


babel --plugins transform-class-properties script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-class-properties"]



boolean, defaults to false.

Class properties are compiled to use Object.defineProperty. Static fields are now defined even if they are not initialized.


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