# Solidity and hardhat automatically remove console logs

By [N00b21337](https://paragraph.com/@n00b21337) · 2023-01-12

---

There is nice plugin that I use as default for my hardhat setup and that is **hardhat-preprocessor,** so let’s install it

[https://www.npmjs.com/package/hardhat-preprocessor](https://www.npmjs.com/package/hardhat-preprocessor)

and depending on if you are using TS or plain JS you would add this in .js config

    const { removeConsoleLog } = require("hardhat-preprocessor");
    

and then at start of your config file you define which networks you want to make clean and without console.log statements and import

    module.exports = {
        defaultNetwork: "hardhat",
        preprocess: {
            eachLine: removeConsoleLog((hre) => hre.network.name !== "hardhat" && hre.network.name !== "localhost"),
        },
    

and it will remove it on compile, so you don’t have a tedious task of manually removing it.

---

*Originally published on [N00b21337](https://paragraph.com/@n00b21337/solidity-and-hardhat-automatically-remove-console-logs)*
