npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

formik-migrate

v0.2.0

Published

Smart Formik to React Hook Form migration - analyze, convert, and validate automatically

Readme

formik-migrate

The smart way to migrate from Formik to React Hook Form.

Analyze your codebase, auto-convert simple patterns, and get a clear migration plan for everything else.

npm version npm downloads License: MIT

Features

  • Analyze your codebase and find all Formik usage
  • Auto-convert simple patterns (~80% of code)
  • Watch mode - re-analyze on file changes
  • HTML reports - visual migration dashboard
  • Zod support - convert Yup schemas to Zod (experimental)
  • GitHub Action - block PRs that add new Formik code
  • Safe - only converts what it understands

Why Migrate from Formik?

Formik is unmaintained - last update was over 2 years ago.
React Hook Form is the future - better performance, active maintenance, 9M weekly downloads.

But manual migration is painful and takes days or weeks for large codebases.

That's where formik-migrate helps.


What It Does

Analyzes your codebase - finds all Formik usage
Auto-converts simple patterns (~80% of code)
Flags complex cases that need manual review
Shows time/cost savings
Safe - only converts what it understands


Quick Start

1. Install

npx formik-migrate analyze

No installation needed! Use with npx.

Or install globally:

npm install -g formik-migrate

2. Analyze Your Codebase

formik-migrate analyze

This scans your project and shows:

  • How many files use Formik
  • What can be auto-converted
  • What needs manual review
  • Time/cost estimates

3. Convert Simple Patterns

formik-migrate convert --backup

This:

  • Auto-converts simple useFormikuseForm
  • Transforms simple <Field> → native <input>
  • Creates backups of original files
  • Flags complex patterns for you to review

Example Output

╔══════════════════════════════════════════════════════════════╗
║         Formik → React Hook Form Migration Analysis         ║
╚══════════════════════════════════════════════════════════════╝

📊 Summary:
   • Total Files: 156
   • Files Using Formik: 23
   • Auto-Convertible: 18 ✓
   • Manual Review: 5 ⚠️

⏱️  Time Estimates:
   Manual migration:        12.5 hours
   With formik-migrate:     3.2 hours
   Time saved:              9.3 hours

💰 ROI (@ $100/hr):
   Manual cost:             $1,250
   Savings:                 $930

What Gets Auto-Converted

✅ Simple useFormik

Before:

import { useFormik } from 'formik';

const formik = useFormik({
  initialValues: { email: '', password: '' },
  validationSchema: loginSchema,
  onSubmit: (values) => { /* ... */ },
});

After:

import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';

const form = useForm({
  defaultValues: { email: '', password: '' },
  resolver: yupResolver(loginSchema),
});

✅ Simple Fields

Before:

<Field name="email" type="email" />

After:

<input {...register("email")} type="email" />

What Needs Manual Review

⚠️ Complex Validation

// Custom validate function
validate: (values) => { /* complex logic */ }

Solution: Convert to Zod or Yup schema

⚠️ Custom Field Components

<Field name="email" component={CustomInput} />

Solution: Use Controller from React Hook Form

⚠️ Field Arrays with Complex Logic

<FieldArray name="items" render={({ push, remove }) => (
  // Complex nested logic
)} />

Solution: Use useFieldArray hook


CLI Commands

analyze [directory]

Analyze Formik usage in your codebase.

# Analyze current directory
formik-migrate analyze

# Analyze specific directory
formik-migrate analyze ./src

# Save report to file
formik-migrate analyze --output report.md

# JSON output
formik-migrate analyze --format json

Options:

  • -f, --format <format> - Output format (console, json, markdown, html)
  • -o, --output <file> - Save report to file
  • -w, --watch - Watch mode - re-analyze on file changes
  • --html <file> - Generate HTML report

convert [directory]

Convert Formik code to React Hook Form.

# Preview changes (dry run)
formik-migrate convert --dry-run

# Convert with backups
formik-migrate convert --backup

# Convert without confirmation
formik-migrate convert --yes

Options:

  • -d, --dry-run - Preview without modifying files
  • -b, --backup - Create .backup files
  • -y, --yes - Skip confirmation prompts
  • --zod - Convert Yup schemas to Zod (experimental)

stats [directory]

Quick summary of Formik usage.

formik-migrate stats

Watch Mode

Re-analyze automatically when files change:

formik-migrate analyze --watch

Great for monitoring migration progress during development.


HTML Reports

Generate an interactive HTML dashboard:

formik-migrate analyze --html report.html

The report shows:

  • Migration progress visualization
  • Pattern breakdown (useFormik, Field, FieldArray, etc.)
  • File-by-file status
  • Time estimates

Zod Support (Experimental)

Convert Yup validation schemas to Zod:

formik-migrate convert --zod --backup

Yup:

Yup.object({
  email: Yup.string().email().required(),
  age: Yup.number().min(18).required(),
})

Converted to Zod:

z.object({
  email: z.string().email(),
  age: z.number().min(18),
})

Note: Complex validation patterns may need manual adjustment.


GitHub Action

Block PRs that add new Formik code:

# .github/workflows/formik-check.yml
name: Check Formik Usage

on: [pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: willzhangfly/formik-migrate@v1
        with:
          fail-on-formik: false      # Fail if ANY Formik found
          max-formik-files: 10       # Fail if more than 10 files use Formik
          comment-on-pr: true        # Add analysis comment to PR

Inputs: | Input | Default | Description | |-------|---------|-------------| | path | . | Project directory | | fail-on-formik | false | Fail if any Formik usage | | max-formik-files | 0 | Max files with Formik (0 = no limit) | | comment-on-pr | true | Add comment to PR |

Outputs:

  • formik-files - Number of files using Formik
  • auto-convertible - Patterns that can be auto-converted
  • manual-review - Patterns needing manual review

Real-World Example

Before Migration

import { useFormik } from 'formik';
import * as Yup from 'yup';

const LoginForm = () => {
  const formik = useFormik({
    initialValues: {
      email: '',
      password: '',
    },
    validationSchema: Yup.object({
      email: Yup.string().email().required(),
      password: Yup.string().min(8).required(),
    }),
    onSubmit: async (values) => {
      await login(values);
    },
  });

  return (
    <form onSubmit={formik.handleSubmit}>
      <input
        name="email"
        value={formik.values.email}
        onChange={formik.handleChange}
        onBlur={formik.handleBlur}
      />
      {formik.errors.email && <span>{formik.errors.email}</span>}
      
      <input
        name="password"
        type="password"
        value={formik.values.password}
        onChange={formik.handleChange}
        onBlur={formik.handleBlur}
      />
      {formik.errors.password && <span>{formik.errors.password}</span>}
      
      <button type="submit">Login</button>
    </form>
  );
};

After Migration (Auto-Converted)

import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import * as Yup from 'yup';

const LoginForm = () => {
  const { register, handleSubmit, formState: { errors } } = useForm({
    defaultValues: {
      email: '',
      password: '',
    },
    resolver: yupResolver(
      Yup.object({
        email: Yup.string().email().required(),
        password: Yup.string().min(8).required(),
      })
    ),
  });

  const onSubmit = async (values) => {
    await login(values);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register("email")} />
      {errors.email && <span>{errors.email.message}</span>}
      
      <input {...register("password")} type="password" />
      {errors.password && <span>{errors.password.message}</span>}
      
      <button type="submit">Login</button>
    </form>
  );
};

What changed:

  • useFormikuseForm
  • initialValuesdefaultValues
  • validationSchemaresolver: yupResolver(...)
  • ✅ Manual field props → {...register("name")}
  • formik.errorserrors from formState

Performance improvement: ~70% fewer re-renders!


Safety Features

formik-migrate is conservative - it only converts what it's 100% sure about.

  1. Analyzes first - shows you exactly what will change
  2. Converts safely - only simple, well-understood patterns
  3. Flags complex cases - so you can review them manually
  4. Creates backups - use --backup flag
  5. Dry-run mode - preview with --dry-run

You stay in control.


Migration Checklist

After running formik-migrate convert:

  • [ ] Install dependencies: npm install react-hook-form @hookform/resolvers
  • [ ] Review changes: git diff
  • [ ] Fix flagged items (tool shows you which ones)
  • [ ] Test all forms thoroughly
  • [ ] Update tests (form state structure changes)
  • [ ] Deploy to staging
  • [ ] Monitor for issues
  • [ ] Deploy to production 🎉

When to Use This Tool

Good fit:

  • ✅ You have 5+ forms using Formik
  • ✅ Most forms are simple (useFormik with initialValues + validationSchema)
  • ✅ You want to save time on migration
  • ✅ You need a migration plan

Maybe not:

  • ❌ You have 1-2 simple forms (just migrate manually)
  • ❌ All your forms are highly complex (still useful for analysis though!)

Comparison: Manual vs. formik-migrate

| Aspect | Manual Migration | With formik-migrate | |--------|------------------|---------------------| | Time for 20 forms | 2-3 days | 3-4 hours | | Risk of errors | High | Low | | Missed patterns | Common | Flagged automatically | | Documentation | You have to write it | Generated for you | | Confidence | Low (easy to miss things) | High (analyzed & tested) |


Support This Tool ☕

formik-migrate is 100% free and open source.

If it saved you time, consider buying me a coffee:

💚 Buy Me a Coffee

This tool saves hours of work. If it helped you, a small tip helps me keep building!

No subscriptions. No paywalls. Just good vibes.


Testimonials

"Saved us 2 weeks of manual migration work. Found patterns we would have missed."
— React Developer at Tech Startup

"The analysis alone was worth it. Showed us exactly what we were dealing with."
— Frontend Lead at SaaS Company


FAQ

Q: Will this break my forms?
A: No. The tool only converts simple patterns it's 100% sure about. Everything else is flagged for manual review.

Q: What if I don't use Yup? A: We support both Yup and Zod! Use --zod flag to convert Yup schemas to Zod automatically.

Q: Can I undo the changes?
A: Yes! Use --backup flag to create backup files. Or just use git to revert.

Q: What about TypeScript?
A: Fully supported! Works with .ts and .tsx files.

Q: Does this handle custom Field components?
A: The tool flags them for manual review. You'll need to convert those yourself.


Support


License

MIT


Contributing

Contributions welcome! See CONTRIBUTING.md


Built to make Formik → React Hook Form migration painless.

If this saved you time, give it a ⭐️ on GitHub!