What is Visualforce in Salesforce?
Updated · By the Clientell AI team · How we write
Visualforce is a tag-based markup language and framework that developers use to build custom pages on the Salesforce platform. A page mixes tags, like apex:page, with a controller that supplies the data. It runs in Lightning Experience and Salesforce Classic. For new work, Salesforce recommends Lightning web components.
Key facts
- What it is
- A tag-based markup language, similar to HTML, for custom Salesforce pages (Developer Guide)
- Data and logic
- Standard controllers, custom Apex controllers and controller extensions (Developer Guide)
- Where it runs
- Desktop browsers (Lightning Experience and Classic) and the Salesforce mobile app
- View state limit
- 170KB maximum per Visualforce page (Developer Limits)
- Newer option
- Lightning web components, which Salesforce recommends for new development (Developer Guide). See Lightning web components.
Clientell AI, the AI Salesforce admin, helps with Visualforce in a sandbox: it writes and tests the code, and shows it to you before anything deploys. See Apex and query generation
Try it in Clientell AI
“Write a Visualforce example for my Account object, test it in a sandbox, and show me the code before anything deploys.”
Clientell AI reads your org first. Platform deployments include rollback. How security works.
What is Visualforce in Salesforce?
Visualforce is a framework with a tag-based markup language. It lets developers build wizards, multistep processes and custom screens, and customize the Salesforce user interface (Developer Guide).
A Visualforce page is a file of markup. Salesforce turns the tags into HTML when a user opens the page. Tags exist for common interface parts, such as forms, input fields, related lists and detail views.
People also search for it as "Visual Force". It is the same thing.
How does a Visualforce page work?
A page has two parts. The markup defines what the user sees. A controller defines what happens when the user clicks, and it supplies the data.
A standard controller gives you the same logic as the built-in Salesforce pages. With the standard Account controller, Save on your page behaves like Save on the normal Account edit page (Developer Guide). When you need more, you write a custom controller or an extension in Apex.
This short page shows the detail view of one account, with no Apex at all. Expressions that bind a field, such as the account name, are wrapped in curly braces and start with an exclamation mark. Add them when you need to read or write one field.
<apex:page standardController="Account">
<apex:pageBlock title="Account detail">
<apex:detail relatedList="false" title="false"/>
</apex:pageBlock>
</apex:page>How do you create and open a Visualforce page?
Use a sandbox. Open the page by its URL path to test it.
- Setup > Custom Code > Visualforce Pages > New.
- Enter a label and a name, for example AccountEdit.
- Paste the markup above and click Save.
- Open /apex/AccountEdit with an Account record Id in the URL, for example ?id=001... to see the form.
- Result: the page shows the standard Account detail fields for that record.
- To let other users in, add the page to their profile or permission set under Visualforce Page Access.
Visualforce vs Lightning web components
Salesforce recommends Lightning Experience low-code tools and Lightning web components (LWC) over Visualforce for new development (Developer Guide). Visualforce is still supported, and many orgs run old pages that work fine.
| Visualforce | Lightning web components | |
|---|---|---|
| Style | Server-rendered tag markup | Modern JavaScript web standards |
| Where it fits | Existing pages, PDF output, email templates, Classic | New Lightning Experience screens |
| Data access | Controllers written in Apex | Apex, plus data services built into the Lightning platform |
| Salesforce guidance | Supported, not recommended for new work | Recommended for new development |
What limits and mistakes should you know?
A Visualforce page has a maximum view state size of 170KB (Developer Limits). The view state is the data Salesforce keeps between page requests so forms work. Large forms and big collections in a controller can push a page over it (Developer Guide).
- Loading too much data. Fix: filter SOQL and use pagination, since pages have a response limit of under 15 MB (Developer Guide).
- Keeping big lists in public controller variables. Fix: mark them transient or query them again when needed.
- Rebuilding a page that already works. Fix: leave stable Visualforce alone and build new screens in LWC.
- Forgetting access. Fix: Visualforce page access is a permission on profiles and permission sets, so check it before you debug the code.
FAQ: Visualforce in Salesforce
What is Visualforce in Salesforce?
Visualforce is a tag-based markup language and framework for building custom pages on the Salesforce platform. Pages use controllers, written in Apex or supplied by Salesforce, for their data and logic.
What is a Visualforce page in Salesforce?
A Visualforce page is a file of markup that Salesforce turns into HTML when a user opens it. It is usually paired with a standard or custom Apex controller.
Is Visualforce still used?
Yes. It is still supported, and many orgs run Visualforce pages. For new development, Salesforce recommends Lightning web components (Developer Guide).
What is the difference between Visualforce and Apex?
Visualforce is the page layer: markup that draws the screen. Apex is the code language for the controller behind it. A page can use a standard controller with no Apex at all.
What is the Visualforce view state limit?
The maximum view state size for a Visualforce page is 170KB (Developer Limits).
Is Visual Force the same as Visualforce?
Yes. People search for both spellings, but the product name is Visualforce, written as one word.
Sources: Visualforce Developer Guide: Introducing Visualforce, Visualforce Developer Guide: Visualforce or Lightning Web Components, Visualforce Developer Guide: Standard Controllers, Visualforce Developer Guide: Optimize the View State, Salesforce Developer Limits: Visualforce Limits. Last reviewed .
Related Salesforce Terms
2 termsLightning Web Components (LWC)
DevelopmentLightning Web Components is Salesforce's modern UI framework built on native web standards like Web Components, Shadow DOM, and ES modules.
Lightning Experience
PlatformLightning Experience is Salesforce's modern user interface, replacing Salesforce Classic with a component-based, responsive design optimized for productivity.
What should I read next?
More in Development
View all →Apex
Apex is Salesforce's proprietary, strongly-typed programming language used to execute custom business logic on the Lightning Platform.
Lightning Web Components (LWC)
Lightning Web Components is Salesforce's modern UI framework built on native web standards like Web Components, Shadow DOM, and ES modules.
SOQL
SOQL (Salesforce Object Query Language) is the query language that reads records from Salesforce objects, much like SQL SELECT. Apex allows 100 SOQL queries per synchronous transaction and 200 per asynchronous one.
SOSL
SOSL (Salesforce Object Search Language) is a text-search language that looks across several objects in one call and returns a list of lists. Apex allows 20 SOSL queries per transaction, separate from the SOQL limit.
Try this on your own org
Start the 14-day free trial, no card. Clientell AI asks before it changes anything in production.
14-day free trial · No credit card required