GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hckhanh/format-prompt: A utility to format prompts for a cleaner presentation and optimal token usage. Removes unused spaces and line breaks, and supports template literals.

BranchesTags
Open more actions menu

Latest commit

 

History

286 Commits
286 Commits

Folders and files

NameName
Last commit message
Last commit date
.changeset
.changeset
 
 
.github
.github
 
 
benchmark
benchmark
 
 
docs/images
docs/images
 
 
src
src
 
 
test
test
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
.knip.json
.knip.json
 
 
.syncpackrc.json
.syncpackrc.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
biome.json
biome.json
 
 
bun.lock
bun.lock
 
 
bunfig.toml
bunfig.toml
 
 
codecov.yml
codecov.yml
 
 
context7.json
context7.json
 
 
deno.json
deno.json
 
 
deno.lock
deno.lock
 
 
mise.toml
mise.toml
 
 
package.json
package.json
 
 
prompt-call.png
prompt-call.png
 
 
renovate.json
renovate.json
 
 
tsconfig.json
tsconfig.json
 
 
tsdown.config.ts
tsdown.config.ts
 
 
vitest.config.mts
vitest.config.mts
 
 

Repository files navigation

format-prompt! NPM Downloads JSR

format-prompt

A utility to format prompts for a cleaner presentation and optimal token usage. Removes unused spaces and line breaks, and supports template literals.

Documentation

https://docs.khanh.id/format-prompt

Test codecov Quality Gate Status Bundle Size CodSpeed Badge

Installation

# Using npm
npm install format-prompt

# Using bun
bun add format-prompt

# Using JSR (recommended for Deno)
deno add jsr:@hckhanh/format-prompt

Usage

It can convert a prompt from:

        
    
                        
                        You are a security guard that analyze the given email for spam/scam/toxicity/business relevance:
  
      
                          
            Score each category and provide recommendation. Focus on:
              * Spam: unsolicited bulk/promotional content
              * Scam: phishing, fraud, identity theft attempts
              * Toxicity: hate speech, threats, harassment
              * Business relevance: legitimate business inquiries, job opportunities
              * Suspicious patterns: urgent language, poor grammar, suspicious URLs, sensitive info requests
              * Advertisement: explicit promotional content, product/service offers, marketing campaigns

                        If you are not sure about any links, emails or any information, use tools.
            
            ${encode({ demo: 1, array: [1, 2, 3], nested: { a: 'b' } })}

            If you are not sure about any links, emails or any information, use tools.
            
            
            ${encode({ demo: 1, array: [1, 2, 3], nested: { a: 'b' } })}
            
            
            
            
            

into this:

You are a security guard that analyze the given email for spam/scam/toxicity/business relevance:
                          
Score each category and provide recommendation. Focus on:
* Spam: unsolicited bulk/promotional content
* Scam: phishing, fraud, identity theft attempts
* Toxicity: hate speech, threats, harassment
* Business relevance: legitimate business inquiries, job opportunities
* Suspicious patterns: urgent language, poor grammar, suspicious URLs, sensitive info requests
* Advertisement: explicit promotional content, product/service offers, marketing campaigns

If you are not sure about any links, emails or any information, use tools.

demo: 1
array[3]: 1,2,3
nested:
  a: b

If you are not sure about any links, emails or any information, use tools.

demo: 1
array[3]: 1,2,3
nested:
  a: b

It will allow you to have a prettier prompt in your code without worrying about extra spaces or line breaks affecting the prompt quality.

prompt-call.png

About

A utility to format prompts for a cleaner presentation and optimal token usage. Removes unused spaces and line breaks, and supports template literals.

docs.khanh.id/format-prompt

Topics

aiai-agentsjavascriptjspromptprompt-toolkitstringstring-template-literalstypescript

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.