Online c function prototype header generator tool

Note: latest code on my laptop. Refactoring and improving for code release.

Really simple concept: scan an input c file, find the functions that need prototype declarations, and then output the prototype declarations for you to copy and paste into a header or at the top of your file.

I use this simple tool when quickly prototyping microcontroller c code. Just write your code without worrying about declaring function prototypes, then copy and paste the code into this tool and it will create the declarations for all functions that have not been declared yet. No rocket science going on, just saves you some time.

You can also use this tool to merge additions to your header file if you have a number of functions that you forgot to declare. Just paste the header and source files together in here and let the script spit out the missing declarations to add to the header.

Keep in mind that this tool is intended for quick prototyping. If you are making something complicated, best plan out your headers. Don't blame me for helping you be lazy :)

pre load brushes

not empty
not empty
NOTE! this script is a proof of concept hacked together with a bunch of large regex patterns so be realistic with what you expect from it! Performance could be drastically improved if javascript had possessive quantifiers (sad face).

Sort by: then by: then by:

include guard: append: wtf?

Existing declarations/header (so we can skip identical declarations):


get larger example c | get huge/complex example

//click the button!

nothing yet

Use at your own risk... blah blah... however you see fit (license).


  • Because the tool uses regular expressions and not full parsing, I'm sure occasional errors will occur (especially around funky macro usage). Keep an eye out, but it should be helpful in many cases.
  • Captured comments must follow the doxygen format . We also accept a single "///" line instead of requiring "at least two C++ comment lines" for the truley lazy :)


  • TODO: compile regular expressions once
  • TODO: better support for additional keywords like 'static'
  • TODO: better general parsing respecting strings
  • TODO (maybe): support for old c function definitions "int main(argc, argv) int argc; char *argv[]; {"
  • TODO (maybe): use a ported regex engine (perl? python?). Possessive quantifiers would make a HUGE difference while parsing strings and block comments (otherwise we can have catastrophic backtracking).
  • TODO (mabye): improve function signature matching for strings with "," in them, and extern keyword...
  • TODO (maybe): ability to extract/remove existing declarations (in case you sloppily declared them throughout your source), so that you can move them to the top of your code or to a header file...
  • TODO (maybe): improve function detection. Wouldn't find multiple declarations on the same line right now.
  • done: improve general parsing to respect block comments (don't want to accidentally find function declarations/definitions in large block comments)
  • done: copy doxygen style comments


  1. Tony Zampini says:

    Hi Adam,
    I just used your function prototype tool, and it saved me a ton of time!!. Thank you for sharing. If you are looking for suggestions, I have one. My C project has about 20 source files, so I had to cut/paste 20 times. It would unbelievably great if, instead of using the source as input, a list of C filenames could be used as input. Then your script could upload the files create prototypes for the entire project at once. Just a suggestion. Thanks again for your effort in developing this. Tony

    1. Adam Fraser-Kruck says:

      Hi Tony!

      glad you like it. I actually find my self using it quite a bit.

      I'm hesitant to upload files because I don't want to handle people's code or have them question the security of it. This current generator doesn't send your code anywhere. All the processing is done right in your browser with no transmission anywhere.

      That said, I am slowing working away on an offline tool that we can use to take care of things like this. It will be like a code assistant. Generate prototypes, create "toString" methods for enums, create validators/iterators for enums, all the monotonous things that are simple but time consuming and error prone to maintain.

      The tool will also be written in Typescript (a form of Javascript) to make customization and editing easier.


      1. Paul says:

        Hey, thank you so much for your tool! I think you don't really have to upload it to your server just into the browsers memory using the javscript filereader api. The code would stay on the client machine and you could either generate the h files and print the extracted functions or trigger a download (to avoid pasting of 20 .h files)

        1. Adam Fraser-Kruck says:

          Good point Paul. The filereader api could be really handy.

          That said, I don't often need to do batches of files. It's usually just the one or two files that I'm working on.

          How do you use it?

          1. Paul says:

            Hi Adam,

            I wouldn't need batch processing either but I think it would be a cool feature and make your tool even better :)

            It should be really easy to implement maybe I will have a look if I find time on the weekend and only if you don't mind?

          2. Adam Fraser-Kruck says:

            Hi Paul,

            I'd be happy to collaborate!

            It would be ideal if you could write the code so that it wasn't coupled too closely to the function prototype extraction as I may rewrite that in the future.


        2. Adam Fraser-Kruck says:

          Hey Paul,

          you can send me an email at afk@olkie.com to work out any details that come up. Looking forward to trying out the drag and drop functionality :)


          1. Paul says:

            Hey Adam,

            have you seen my mail?

            I know I took a while... :)

  2. Gary Fitts says:

    Wonderful tool! I've often wondered why C compilers don't have a prototype generation option.

    One tiny bug I've found: this causes the generator to miss the definition of foo()

    int foo() // comment

    1. Adam Fraser-Kruck says:

      Thanks for reporting Gary! I hadn't anticipated that. Will fix in next release.


  3. Sebastian says:

    Hi Adam,

    great work, good tool!!!

    I think, I found a bug.

    void foo(void)
    int test = 0;

    with this kind of commentar the generator did not recognize the function.

    1. Adam Fraser-Kruck says:

      Yep! That's a bug. Thanks for taking the time to report it :)

  4. mk says:

    may the love of the penguins take over your soul

Leave a Reply

Your email address will not be published. Required fields are marked *