8000
Skip to content

kamilstanuch/doc2form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doc2Form — Convert PDF, Word & Docs to Google Forms with Gemini AI (Free)

Open source · Runs in your Google account · No separate server

License: MIT Google Apps Script Gemini AI PRs Welcome

What is Doc2Form?  ·  How it works  ·  Features  ·  Demos  ·  Setup  ·  Use cases  ·  FAQ  ·  Project structure  ·  Customization  ·  Contributing


What is Doc2Form?

Tired of receiving PDFs and Word docs that should've been a Google Form? Same.

Doc2Form is a free, open-source Google Apps Script that uses Gemini AI to turn any PDF or Word file into a fully functional Google Form — or you describe the form in plain English and it builds it for you.

Use it to convert PDF to Google Form, Word to Google Form, or build a form from a plain-English prompt — powered by Gemini AI and the Google Forms API, with no separate server.

No servers. No hosting. No costs beyond the free Gemini API tier. Everything stays inside your Google account. Prefer zero setup? Use the hosted app at doc2form.dev.

The core idea: upload a document or type what you need; Gemini returns structured form data; the Google Forms API creates the form you can edit and share.

Use cases

  • Educators — Turn quiz PDFs, worksheets, and Word tests into Google Forms.
  • HR & recruiters — Digitize intake and application PDFs without retyping every field.
  • Developers — Generate forms from Apps Script with Gemini; data stays in the deployer’s Google account.

FAQ

How do I convert a PDF to a Google Form?

Upload the PDF in your deployed web app (see setup below). Doc2Form sends content to Gemini for structure, then creates the form via the Google Forms API. The same flow works for Word (.docx) files.

Is there a free PDF to Google Form tool?

Yes. This project is MIT-licensed and free to run; you use your own free Gemini API tier. Processing happens in your Google Workspace context—not on a third-party document host.

Can I create a form without uploading a file?

Yes. Use the Describe a form tab: type what you need (for example, a feedback survey with scales), and Gemini builds the form structure. That plain English → Google Form path is one of Doc2Form’s strengths.

Demos

Upload a document — PDF or Word → Google Form
Doc2Form demo: upload a PDF and generate a Google Form

Describe a form — type what you need in the Describe a form tab → Google Form
Doc2Form demo: describe a form in plain English and generate a Google Form


How It Works

┌─────────────────────────────────────────────────────────────────┐
│                          YOU                                    │
│                                                                 │
│   ┌──────────────┐     OR     ┌──────────────────────────┐      │
│   │  📄 Upload   │           │  ✏️  Describe a form      │      │
│   │  PDF / Word  │           │  "Create a feedback       │      │
│   │              │           │   survey with scales..."   │      │
│   └──────┬───────┘           └────────────┬──────────────┘      │
└──────────┼────────────────────────────────┼─────────────────────┘
           │                                │
           ▼                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                   Google Apps Script                             │
│                                                                 │
│   .docx → Mammoth.js extracts text                              │
│   .pdf  → sent as base64 binary                                 │
│                                                                 │
│          ┌────────────────────────────┐                          │
│          │  🤖 Gemini AI              │                          │
│          │  Analyzes content →        │                          │
│          │  Returns structured JSON   │                          │
│          │  with questions, types,    │                          │
│          │  options, and settings     │                          │
│          └────────────┬───────────────┘                          │
│                       │                                         │
│                       ▼                                         │
│          ┌────────────────────────────┐                          │
│          │  📋 Google Forms API       │                          │
│          │  Builds the form with      │                          │
│          │  11 question types,        │                          │
│          │  sections, and validation  │                          │
│          └────────────┬───────────────┘                          │
└───────────────────────┼─────────────────────────────────────────┘
                        │
                        ▼
          ┌──────────────────────────────┐
          │  ✅ Your Google Form         │
          │                              │
          │  📝 Edit link (for you)      │
          │  🔗 Share link (for others)  │
          │  📋 One-click copy           │
          └──────────────────────────────┘

Features

Feature
📄 Upload PDF or Word AI reads it, extracts fields, builds a form
✏️ Describe in plain English "Create a 10-question feedback survey" → done
🎯 8 ready-made templates Feedback, RSVP, job application, quiz, and more
📊 11 question types Short answer, scales, grids, dates, dropdowns...
🔗 Both links returned Edit link + share link with one-click copy
🆓 100% free No server, no hosting, no costs

Setup (5 minutes)

Prefer to skip this? doc2form.dev is a hosted version — no API keys, no deployment, no configuration needed.

1. Get a Gemini API Key

  1. Go to Google AI Studio
  2. Click Create API Key
  3. Copy the key — you'll need it in step 3

2. Create the Apps Script Project

  1. Go to Google Apps Script and click New Project
  2. Delete the default Code.gs content
  3. Copy the contents of each file into your project:
This repo Apps Script file How to create
code.gs Code.gs Replace the default file
Prompts.gs Prompts.gs File → New → Script
Index.html Index.html File → New → HTML
appsscript.json appsscript.json See note below

To edit appsscript.json: Click the gear icon (⚙️ Project Settings) → check "Show 'appsscript.json' manifest file in editor" → go back to Editor and edit the file.

Google Apps Script setup

3. Add Your API Key

  1. In Apps Script, click ⚙️ Project Settings
  2. Scroll to Script Properties
  3. Click Add Script Property
  4. Set:
    • Property: GEMINI_API_KEY
    • Value: (paste your key)
  5. Save

4. Deploy as Web App

  1. Click DeployNew deployment
  2. Click the gear icon → select Web app
  3. Set:
    • Description: Doc2Form
    • Execute as: Me
    • Who has access: Anyone (or restrict as needed)
  4. Click Deploy
  5. Authorize the app when prompted
  6. Copy the web app URL — that's your Doc2Form!

Alternative: Use clasp (for developers)

If you prefer working locally with version control:

npm install -g @google/clasp
clasp login
clasp create --type webapp --title "Doc2Form"
clasp push
clasp deploy

See .clasp.json.example for the config format.

Project Structure

├── code.gs            # Main backend — Gemini API calls, form builder, validation
├── Prompts.gs         # Predefined prompt templates (easy to customize)
├── Index.html         # Frontend UI — tabs, file upload, templates, results
├── appsscript.json    # Apps Script manifest (scopes, runtime config)
├── screenshots/       # README images & demo GIFs (PDF upload + prompt flows)
└── README.md

Customization

Add Your Own Templates

Open Prompts.gs and add entries to the PROMPT_TEMPLATES array:

{
  id: 'mytemplate',
  name: 'My Custom Template',
  icon: 'star',                        // Any Material Icons Outlined name
  description: 'What this template does',
  prompt: 'The full prompt text that describes the form to generate...'
}

Icons: browse Material Icons for icon names.

Change the AI Model

In code.gs, change the model variable:

var model = 'gemini-2.5-flash';   // Fast & capable (default)
var model = 'gemini-2.5-pro';     // More powerful, slower

Supported Question Types

Type Google Forms equivalent
SHORT_ANSWER Short text field
PARAGRAPH Long text field
MULTIPLE_CHOICE Radio buttons
CHECKBOX Checkboxes
DROPDOWN Dropdown menu
LINEAR_SCALE 1-5 or 1-10 scale
DATE Date picker
TIME Time picker
MULTIPLE_CHOICE_GRID Grid with radio buttons
CHECKBOX_GRID Grid with checkboxes
SECTION_HEADER Page/section break

Limitations

  • File size: 5 MB max (Apps Script constraint)
  • PDF quality: Gemini handles most PDFs well, but heavily scanned/image-based PDFs may produce less accurate results
  • Rate limits: The free Gemini API has usage limits — if you hit them, wait a minute and try again
  • Google Apps Script quotas: Standard quotas apply

Contributing

PRs welcome! Some ideas:

  • Image-based question support
  • Form preview before creation
  • Batch processing (multiple files → multiple forms)
  • Export form structure as JSON
  • Dark mode

Built With

Technology Role
Google Apps Script Google Apps Script Runtime & hosting
Gemini Gemini 2.5 Flash Document analysis & form structuring
Google Forms Google Forms API Form creation
Mammoth Mammoth.js Word (.docx) text extraction

License

MIT — do whatever you want with it. See LICENSE.


If this saved you from another PDF form, consider giving it a star.

About

Convert any PDF, Word doc, or text prompt into a Google Form using Gemini AI — free, open-source Google Apps Script. No servers needed.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

0