This module allows returning composer commands to add/remove modules in/from composer.json.

Installation

composer require drupal/sync_composer_with_contrib
Note:
This module will install "mcstreetguy/composer-parser" as a dependency,

How to use it!

After the installation, go to /admin/generate-composer-commands, you'll see different composer commands (composer require or composer remove), it will help you to sync contrib modules with composer.json and uninstall unnecessary modules.